protoc 2.6.1.1 → 2.6.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (479) hide show
  1. checksums.yaml +4 -4
  2. data/ext/protoc/Makefile.in +10 -13
  3. data/ext/protoc/extconf.rb +0 -1
  4. data/ext/protoc/protobuf/CHANGES.txt +593 -0
  5. data/ext/protoc/protobuf/CONTRIBUTORS.txt +93 -0
  6. data/ext/protoc/protobuf/INSTALL.txt +237 -0
  7. data/ext/protoc/protobuf/LICENSE +33 -0
  8. data/ext/protoc/protobuf/Makefile.am +267 -0
  9. data/ext/protoc/protobuf/README.md +167 -0
  10. data/ext/protoc/protobuf/autogen.sh +41 -0
  11. data/ext/protoc/protobuf/benchmarks/ProtoBench.java +203 -0
  12. data/ext/protoc/protobuf/benchmarks/google_message1.dat +0 -0
  13. data/ext/protoc/protobuf/benchmarks/google_message2.dat +0 -0
  14. data/ext/protoc/protobuf/benchmarks/google_size.proto +136 -0
  15. data/ext/protoc/protobuf/benchmarks/google_speed.proto +136 -0
  16. data/ext/protoc/protobuf/benchmarks/readme.txt +50 -0
  17. data/ext/protoc/protobuf/configure.ac +159 -0
  18. data/ext/protoc/protobuf/editors/README.txt +5 -0
  19. data/ext/protoc/protobuf/editors/proto.vim +105 -0
  20. data/ext/protoc/protobuf/editors/protobuf-mode.el +220 -0
  21. data/ext/protoc/protobuf/examples/AddPerson.java +95 -0
  22. data/ext/protoc/protobuf/examples/ListPeople.java +50 -0
  23. data/ext/protoc/protobuf/examples/Makefile +58 -0
  24. data/ext/protoc/protobuf/examples/README.txt +29 -0
  25. data/ext/protoc/protobuf/examples/add_person.cc +95 -0
  26. data/ext/protoc/protobuf/examples/add_person.py +58 -0
  27. data/ext/protoc/protobuf/examples/addressbook.proto +30 -0
  28. data/ext/protoc/protobuf/examples/list_people.cc +68 -0
  29. data/ext/protoc/protobuf/examples/list_people.py +38 -0
  30. data/ext/protoc/protobuf/generate_descriptor_proto.sh +33 -0
  31. data/ext/protoc/protobuf/java/README.txt +96 -0
  32. data/ext/protoc/protobuf/java/pom.xml +217 -0
  33. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/AbstractMessage.java +466 -0
  34. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/AbstractMessageLite.java +355 -0
  35. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/AbstractParser.java +253 -0
  36. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/BlockingRpcChannel.java +51 -0
  37. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/BlockingService.java +64 -0
  38. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/BoundedByteString.java +163 -0
  39. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/ByteString.java +1022 -0
  40. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/CodedInputStream.java +1311 -0
  41. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/CodedOutputStream.java +1297 -0
  42. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Descriptors.java +2238 -0
  43. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/DynamicMessage.java +622 -0
  44. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Extension.java +96 -0
  45. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/ExtensionRegistry.java +392 -0
  46. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/ExtensionRegistryLite.java +185 -0
  47. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/FieldSet.java +907 -0
  48. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/GeneratedMessage.java +2213 -0
  49. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/GeneratedMessageLite.java +949 -0
  50. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Internal.java +391 -0
  51. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java +122 -0
  52. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/LazyField.java +154 -0
  53. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/LazyFieldLite.java +176 -0
  54. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/LazyStringArrayList.java +367 -0
  55. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/LazyStringList.java +163 -0
  56. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/LiteralByteString.java +362 -0
  57. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Message.java +244 -0
  58. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/MessageLite.java +320 -0
  59. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java +60 -0
  60. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/MessageOrBuilder.java +143 -0
  61. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/MessageReflection.java +931 -0
  62. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Parser.java +261 -0
  63. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/ProtocolMessageEnum.java +58 -0
  64. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/ProtocolStringList.java +48 -0
  65. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java +696 -0
  66. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/RopeByteString.java +957 -0
  67. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/RpcCallback.java +47 -0
  68. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/RpcChannel.java +71 -0
  69. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/RpcController.java +118 -0
  70. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/RpcUtil.java +134 -0
  71. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Service.java +117 -0
  72. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/ServiceException.java +52 -0
  73. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/SingleFieldBuilder.java +241 -0
  74. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/SmallSortedMap.java +618 -0
  75. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/TextFormat.java +1984 -0
  76. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/UninitializedMessageException.java +99 -0
  77. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/UnknownFieldSet.java +995 -0
  78. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java +205 -0
  79. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Utf8.java +349 -0
  80. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/WireFormat.java +163 -0
  81. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/AbstractMessageTest.java +527 -0
  82. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/BoundedByteStringTest.java +68 -0
  83. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/ByteStringTest.java +759 -0
  84. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/CheckUtf8Test.java +141 -0
  85. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/CodedInputStreamTest.java +769 -0
  86. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/CodedOutputStreamTest.java +401 -0
  87. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/DeprecatedFieldTest.java +80 -0
  88. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/DescriptorsTest.java +735 -0
  89. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/DynamicMessageTest.java +326 -0
  90. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/ForceFieldBuildersPreRun.java +48 -0
  91. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/GeneratedMessageTest.java +1515 -0
  92. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/IsValidUtf8Test.java +180 -0
  93. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/IsValidUtf8TestUtil.java +421 -0
  94. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LazyFieldLiteTest.java +134 -0
  95. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LazyFieldTest.java +121 -0
  96. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LazyMessageLiteTest.java +319 -0
  97. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LazyStringArrayListTest.java +174 -0
  98. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LazyStringEndToEndTest.java +143 -0
  99. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LiteEqualsAndHashTest.java +85 -0
  100. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LiteTest.java +148 -0
  101. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LiteralByteStringTest.java +396 -0
  102. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/MessageTest.java +353 -0
  103. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/NestedBuildersTest.java +185 -0
  104. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/ParserTest.java +381 -0
  105. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/RepeatedFieldBuilderTest.java +190 -0
  106. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/RopeByteStringSubstringTest.java +97 -0
  107. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/RopeByteStringTest.java +115 -0
  108. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/ServiceTest.java +320 -0
  109. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/SingleFieldBuilderTest.java +155 -0
  110. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/SmallSortedMapTest.java +420 -0
  111. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/TestBadIdentifiers.java +96 -0
  112. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/TestUtil.java +4124 -0
  113. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/TextFormatTest.java +994 -0
  114. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/UnknownFieldSetTest.java +653 -0
  115. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/UnmodifiableLazyStringListTest.java +227 -0
  116. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/WireFormatTest.java +606 -0
  117. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/lazy_fields_lite.proto +61 -0
  118. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/lite_equals_and_hash.proto +55 -0
  119. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/multiple_files_test.proto +77 -0
  120. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/nested_builders_test.proto +53 -0
  121. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/nested_extension.proto +46 -0
  122. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/nested_extension_lite.proto +48 -0
  123. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/non_nested_extension.proto +49 -0
  124. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/non_nested_extension_lite.proto +50 -0
  125. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/outer_class_name_test.proto +38 -0
  126. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/outer_class_name_test2.proto +42 -0
  127. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/outer_class_name_test3.proto +43 -0
  128. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/test_bad_identifiers.proto +157 -0
  129. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/test_check_utf8.proto +50 -0
  130. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/test_check_utf8_size.proto +51 -0
  131. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/test_custom_options.proto +43 -0
  132. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/test_extra_interfaces.proto +60 -0
  133. data/ext/protoc/protobuf/m4/ac_system_extensions.m4 +37 -0
  134. data/ext/protoc/protobuf/m4/acx_check_suncc.m4 +75 -0
  135. data/ext/protoc/protobuf/m4/acx_pthread.m4 +397 -0
  136. data/ext/protoc/protobuf/m4/stl_hash.m4 +72 -0
  137. data/ext/protoc/protobuf/more_tests/Makefile +41 -0
  138. data/ext/protoc/protobuf/post_process_dist.sh +60 -0
  139. data/ext/protoc/protobuf/protobuf-lite.pc.in +13 -0
  140. data/ext/protoc/protobuf/protobuf.pc.in +14 -0
  141. data/ext/protoc/protobuf/python/README.txt +105 -0
  142. data/ext/protoc/protobuf/python/ez_setup.py +284 -0
  143. data/ext/protoc/protobuf/python/google/__init__.py +1 -0
  144. data/ext/protoc/protobuf/python/google/protobuf/__init__.py +0 -0
  145. data/ext/protoc/protobuf/python/google/protobuf/descriptor.py +849 -0
  146. data/ext/protoc/protobuf/python/google/protobuf/descriptor_database.py +137 -0
  147. data/ext/protoc/protobuf/python/google/protobuf/descriptor_pool.py +643 -0
  148. data/ext/protoc/protobuf/python/google/protobuf/internal/__init__.py +0 -0
  149. data/ext/protoc/protobuf/python/google/protobuf/internal/api_implementation.cc +139 -0
  150. data/ext/protoc/protobuf/python/google/protobuf/internal/api_implementation.py +89 -0
  151. data/ext/protoc/protobuf/python/google/protobuf/internal/api_implementation_default_test.py +63 -0
  152. data/ext/protoc/protobuf/python/google/protobuf/internal/containers.py +269 -0
  153. data/ext/protoc/protobuf/python/google/protobuf/internal/cpp_message.py +663 -0
  154. data/ext/protoc/protobuf/python/google/protobuf/internal/decoder.py +831 -0
  155. data/ext/protoc/protobuf/python/google/protobuf/internal/descriptor_database_test.py +63 -0
  156. data/ext/protoc/protobuf/python/google/protobuf/internal/descriptor_pool_test.py +564 -0
  157. data/ext/protoc/protobuf/python/google/protobuf/internal/descriptor_pool_test1.proto +94 -0
  158. data/ext/protoc/protobuf/python/google/protobuf/internal/descriptor_pool_test2.proto +70 -0
  159. data/ext/protoc/protobuf/python/google/protobuf/internal/descriptor_python_test.py +54 -0
  160. data/ext/protoc/protobuf/python/google/protobuf/internal/descriptor_test.py +669 -0
  161. data/ext/protoc/protobuf/python/google/protobuf/internal/encoder.py +788 -0
  162. data/ext/protoc/protobuf/python/google/protobuf/internal/enum_type_wrapper.py +89 -0
  163. data/ext/protoc/protobuf/python/google/protobuf/internal/factory_test1.proto +57 -0
  164. data/ext/protoc/protobuf/python/google/protobuf/internal/factory_test2.proto +92 -0
  165. data/ext/protoc/protobuf/python/google/protobuf/internal/generator_test.py +343 -0
  166. data/ext/protoc/protobuf/python/google/protobuf/internal/message_factory_python_test.py +54 -0
  167. data/ext/protoc/protobuf/python/google/protobuf/internal/message_factory_test.py +131 -0
  168. data/ext/protoc/protobuf/python/google/protobuf/internal/message_listener.py +78 -0
  169. data/ext/protoc/protobuf/python/google/protobuf/internal/message_python_test.py +54 -0
  170. data/ext/protoc/protobuf/python/google/protobuf/internal/message_test.py +681 -0
  171. data/ext/protoc/protobuf/python/google/protobuf/internal/missing_enum_values.proto +50 -0
  172. data/ext/protoc/protobuf/python/google/protobuf/internal/more_extensions.proto +58 -0
  173. data/ext/protoc/protobuf/python/google/protobuf/internal/more_extensions_dynamic.proto +49 -0
  174. data/ext/protoc/protobuf/python/google/protobuf/internal/more_messages.proto +51 -0
  175. data/ext/protoc/protobuf/python/google/protobuf/internal/python_message.py +1251 -0
  176. data/ext/protoc/protobuf/python/google/protobuf/internal/reflection_test.py +2934 -0
  177. data/ext/protoc/protobuf/python/google/protobuf/internal/service_reflection_test.py +136 -0
  178. data/ext/protoc/protobuf/python/google/protobuf/internal/symbol_database_test.py +120 -0
  179. data/ext/protoc/protobuf/python/google/protobuf/internal/test_bad_identifiers.proto +52 -0
  180. data/ext/protoc/protobuf/python/google/protobuf/internal/test_util.py +662 -0
  181. data/ext/protoc/protobuf/python/google/protobuf/internal/text_encoding_test.py +68 -0
  182. data/ext/protoc/protobuf/python/google/protobuf/internal/text_format_test.py +743 -0
  183. data/ext/protoc/protobuf/python/google/protobuf/internal/type_checkers.py +328 -0
  184. data/ext/protoc/protobuf/python/google/protobuf/internal/unknown_fields_test.py +231 -0
  185. data/ext/protoc/protobuf/python/google/protobuf/internal/wire_format.py +268 -0
  186. data/ext/protoc/protobuf/python/google/protobuf/internal/wire_format_test.py +253 -0
  187. data/ext/protoc/protobuf/python/google/protobuf/message.py +284 -0
  188. data/ext/protoc/protobuf/python/google/protobuf/message_factory.py +155 -0
  189. data/ext/protoc/protobuf/python/google/protobuf/pyext/README +6 -0
  190. data/ext/protoc/protobuf/python/google/protobuf/pyext/__init__.py +0 -0
  191. data/ext/protoc/protobuf/python/google/protobuf/pyext/cpp_message.py +61 -0
  192. data/ext/protoc/protobuf/python/google/protobuf/pyext/descriptor.cc +357 -0
  193. data/ext/protoc/protobuf/python/google/protobuf/pyext/descriptor.h +96 -0
  194. data/ext/protoc/protobuf/python/google/protobuf/pyext/descriptor_cpp2_test.py +58 -0
  195. data/ext/protoc/protobuf/python/google/protobuf/pyext/extension_dict.cc +338 -0
  196. data/ext/protoc/protobuf/python/google/protobuf/pyext/extension_dict.h +123 -0
  197. data/ext/protoc/protobuf/python/google/protobuf/pyext/message.cc +2561 -0
  198. data/ext/protoc/protobuf/python/google/protobuf/pyext/message.h +305 -0
  199. data/ext/protoc/protobuf/python/google/protobuf/pyext/message_factory_cpp2_test.py +56 -0
  200. data/ext/protoc/protobuf/python/google/protobuf/pyext/proto2_api_test.proto +38 -0
  201. data/ext/protoc/protobuf/python/google/protobuf/pyext/python.proto +66 -0
  202. data/ext/protoc/protobuf/python/google/protobuf/pyext/python_protobuf.h +57 -0
  203. data/ext/protoc/protobuf/python/google/protobuf/pyext/reflection_cpp2_generated_test.py +94 -0
  204. data/ext/protoc/protobuf/python/google/protobuf/pyext/repeated_composite_container.cc +763 -0
  205. data/ext/protoc/protobuf/python/google/protobuf/pyext/repeated_composite_container.h +172 -0
  206. data/ext/protoc/protobuf/python/google/protobuf/pyext/repeated_scalar_container.cc +825 -0
  207. data/ext/protoc/protobuf/python/google/protobuf/pyext/repeated_scalar_container.h +112 -0
  208. data/ext/protoc/protobuf/python/google/protobuf/pyext/scoped_pyobject_ptr.h +95 -0
  209. data/ext/protoc/protobuf/python/google/protobuf/reflection.py +205 -0
  210. data/ext/protoc/protobuf/python/google/protobuf/service.py +226 -0
  211. data/ext/protoc/protobuf/python/google/protobuf/service_reflection.py +284 -0
  212. data/ext/protoc/protobuf/python/google/protobuf/symbol_database.py +185 -0
  213. data/ext/protoc/protobuf/python/google/protobuf/text_encoding.py +110 -0
  214. data/ext/protoc/protobuf/python/google/protobuf/text_format.py +873 -0
  215. data/ext/protoc/protobuf/python/mox.py +1401 -0
  216. data/ext/protoc/protobuf/python/setup.py +201 -0
  217. data/ext/protoc/protobuf/python/stubout.py +140 -0
  218. data/ext/protoc/protobuf/src/Makefile.am +418 -0
  219. data/ext/protoc/protobuf/src/google/protobuf/SEBS +240 -0
  220. data/ext/protoc/protobuf/src/google/protobuf/compiler/code_generator.cc +84 -0
  221. data/ext/protoc/protobuf/src/google/protobuf/compiler/code_generator.h +145 -0
  222. data/ext/protoc/protobuf/src/google/protobuf/compiler/command_line_interface.cc +1603 -0
  223. data/ext/protoc/protobuf/src/google/protobuf/compiler/command_line_interface.h +378 -0
  224. data/ext/protoc/protobuf/src/google/protobuf/compiler/command_line_interface_unittest.cc +1654 -0
  225. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc +158 -0
  226. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.cc +288 -0
  227. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.h +103 -0
  228. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.cc +431 -0
  229. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.h +122 -0
  230. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.cc +210 -0
  231. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.h +86 -0
  232. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_field.cc +166 -0
  233. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_field.h +185 -0
  234. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_file.cc +665 -0
  235. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_file.h +99 -0
  236. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.cc +125 -0
  237. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.h +72 -0
  238. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.cc +494 -0
  239. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.h +206 -0
  240. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_message.cc +2645 -0
  241. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_message.h +175 -0
  242. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.cc +375 -0
  243. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.h +121 -0
  244. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_options.h +58 -0
  245. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc +123 -0
  246. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc +451 -0
  247. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.h +123 -0
  248. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_service.cc +334 -0
  249. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_service.h +118 -0
  250. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.cc +642 -0
  251. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.h +127 -0
  252. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto +132 -0
  253. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_unittest.cc +2074 -0
  254. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_unittest.h +51 -0
  255. data/ext/protoc/protobuf/src/google/protobuf/compiler/importer.cc +480 -0
  256. data/ext/protoc/protobuf/src/google/protobuf/compiler/importer.h +317 -0
  257. data/ext/protoc/protobuf/src/google/protobuf/compiler/importer_unittest.cc +617 -0
  258. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_context.cc +195 -0
  259. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_context.h +95 -0
  260. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_doc_comment.cc +233 -0
  261. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_doc_comment.h +69 -0
  262. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_doc_comment_unittest.cc +67 -0
  263. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_enum.cc +333 -0
  264. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_enum.h +99 -0
  265. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_enum_field.cc +778 -0
  266. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_enum_field.h +158 -0
  267. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_extension.cc +207 -0
  268. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_extension.h +109 -0
  269. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_field.cc +213 -0
  270. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_field.h +162 -0
  271. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_file.cc +534 -0
  272. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_file.h +115 -0
  273. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_generator.cc +158 -0
  274. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_generator.h +72 -0
  275. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_generator_factory.cc +77 -0
  276. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_generator_factory.h +101 -0
  277. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_helpers.cc +737 -0
  278. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_helpers.h +322 -0
  279. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_lazy_message_field.cc +826 -0
  280. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_lazy_message_field.h +121 -0
  281. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_message.cc +1666 -0
  282. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_message.h +140 -0
  283. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_message_field.cc +1343 -0
  284. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_message_field.h +173 -0
  285. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_name_resolver.cc +266 -0
  286. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_name_resolver.h +124 -0
  287. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_plugin_unittest.cc +124 -0
  288. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_primitive_field.cc +877 -0
  289. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_primitive_field.h +160 -0
  290. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_service.cc +473 -0
  291. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_service.h +135 -0
  292. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_shared_code_generator.cc +201 -0
  293. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_shared_code_generator.h +90 -0
  294. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_string_field.cc +1056 -0
  295. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_string_field.h +160 -0
  296. data/ext/protoc/protobuf/src/google/protobuf/compiler/main.cc +61 -0
  297. data/ext/protoc/protobuf/src/google/protobuf/compiler/mock_code_generator.cc +240 -0
  298. data/ext/protoc/protobuf/src/google/protobuf/compiler/mock_code_generator.h +117 -0
  299. data/ext/protoc/protobuf/src/google/protobuf/compiler/package_info.h +64 -0
  300. data/ext/protoc/protobuf/src/google/protobuf/compiler/parser.cc +1750 -0
  301. data/ext/protoc/protobuf/src/google/protobuf/compiler/parser.h +522 -0
  302. data/ext/protoc/protobuf/src/google/protobuf/compiler/parser_unittest.cc +2612 -0
  303. data/ext/protoc/protobuf/src/google/protobuf/compiler/plugin.cc +163 -0
  304. data/ext/protoc/protobuf/src/google/protobuf/compiler/plugin.h +72 -0
  305. data/ext/protoc/protobuf/src/google/protobuf/compiler/plugin.pb.cc +1148 -0
  306. data/ext/protoc/protobuf/src/google/protobuf/compiler/plugin.pb.h +897 -0
  307. data/ext/protoc/protobuf/src/google/protobuf/compiler/plugin.proto +147 -0
  308. data/ext/protoc/protobuf/src/google/protobuf/compiler/python/python_generator.cc +1262 -0
  309. data/ext/protoc/protobuf/src/google/protobuf/compiler/python/python_generator.h +166 -0
  310. data/ext/protoc/protobuf/src/google/protobuf/compiler/python/python_plugin_unittest.cc +118 -0
  311. data/ext/protoc/protobuf/src/google/protobuf/compiler/subprocess.cc +463 -0
  312. data/ext/protoc/protobuf/src/google/protobuf/compiler/subprocess.h +108 -0
  313. data/ext/protoc/protobuf/src/google/protobuf/compiler/test_plugin.cc +51 -0
  314. data/ext/protoc/protobuf/src/google/protobuf/compiler/zip_output_unittest.sh +91 -0
  315. data/ext/protoc/protobuf/src/google/protobuf/compiler/zip_writer.cc +218 -0
  316. data/ext/protoc/protobuf/src/google/protobuf/compiler/zip_writer.h +93 -0
  317. data/ext/protoc/protobuf/src/google/protobuf/descriptor.cc +5420 -0
  318. data/ext/protoc/protobuf/src/google/protobuf/descriptor.h +1691 -0
  319. data/ext/protoc/protobuf/src/google/protobuf/descriptor.pb.cc +9135 -0
  320. data/ext/protoc/protobuf/src/google/protobuf/descriptor.pb.h +6761 -0
  321. data/ext/protoc/protobuf/src/google/protobuf/descriptor.proto +687 -0
  322. data/ext/protoc/protobuf/src/google/protobuf/descriptor_database.cc +543 -0
  323. data/ext/protoc/protobuf/src/google/protobuf/descriptor_database.h +369 -0
  324. data/ext/protoc/protobuf/src/google/protobuf/descriptor_database_unittest.cc +748 -0
  325. data/ext/protoc/protobuf/src/google/protobuf/descriptor_pb2_test.py +54 -0
  326. data/ext/protoc/protobuf/src/google/protobuf/descriptor_unittest.cc +5501 -0
  327. data/ext/protoc/protobuf/src/google/protobuf/dynamic_message.cc +764 -0
  328. data/ext/protoc/protobuf/src/google/protobuf/dynamic_message.h +148 -0
  329. data/ext/protoc/protobuf/src/google/protobuf/dynamic_message_unittest.cc +230 -0
  330. data/ext/protoc/protobuf/src/google/protobuf/extension_set.cc +1663 -0
  331. data/ext/protoc/protobuf/src/google/protobuf/extension_set.h +1234 -0
  332. data/ext/protoc/protobuf/src/google/protobuf/extension_set_heavy.cc +734 -0
  333. data/ext/protoc/protobuf/src/google/protobuf/extension_set_unittest.cc +1095 -0
  334. data/ext/protoc/protobuf/src/google/protobuf/generated_enum_reflection.h +91 -0
  335. data/ext/protoc/protobuf/src/google/protobuf/generated_message_reflection.cc +1683 -0
  336. data/ext/protoc/protobuf/src/google/protobuf/generated_message_reflection.h +504 -0
  337. data/ext/protoc/protobuf/src/google/protobuf/generated_message_reflection_unittest.cc +795 -0
  338. data/ext/protoc/protobuf/src/google/protobuf/generated_message_util.cc +65 -0
  339. data/ext/protoc/protobuf/src/google/protobuf/generated_message_util.h +113 -0
  340. data/ext/protoc/protobuf/src/google/protobuf/io/coded_stream.cc +914 -0
  341. data/ext/protoc/protobuf/src/google/protobuf/io/coded_stream.h +1220 -0
  342. data/ext/protoc/protobuf/src/google/protobuf/io/coded_stream_inl.h +69 -0
  343. data/ext/protoc/protobuf/src/google/protobuf/io/coded_stream_unittest.cc +1378 -0
  344. data/ext/protoc/protobuf/src/google/protobuf/io/gzip_stream.cc +326 -0
  345. data/ext/protoc/protobuf/src/google/protobuf/io/gzip_stream.h +209 -0
  346. data/ext/protoc/protobuf/src/google/protobuf/io/gzip_stream_unittest.sh +44 -0
  347. data/ext/protoc/protobuf/src/google/protobuf/io/package_info.h +54 -0
  348. data/ext/protoc/protobuf/src/google/protobuf/io/printer.cc +198 -0
  349. data/ext/protoc/protobuf/src/google/protobuf/io/printer.h +136 -0
  350. data/ext/protoc/protobuf/src/google/protobuf/io/printer_unittest.cc +285 -0
  351. data/ext/protoc/protobuf/src/google/protobuf/io/strtod.cc +113 -0
  352. data/ext/protoc/protobuf/src/google/protobuf/io/strtod.h +50 -0
  353. data/ext/protoc/protobuf/src/google/protobuf/io/tokenizer.cc +1127 -0
  354. data/ext/protoc/protobuf/src/google/protobuf/io/tokenizer.h +402 -0
  355. data/ext/protoc/protobuf/src/google/protobuf/io/tokenizer_unittest.cc +999 -0
  356. data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream.cc +57 -0
  357. data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream.h +248 -0
  358. data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream_impl.cc +473 -0
  359. data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream_impl.h +358 -0
  360. data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc +405 -0
  361. data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h +354 -0
  362. data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream_unittest.cc +965 -0
  363. data/ext/protoc/protobuf/src/google/protobuf/lite_unittest.cc +350 -0
  364. data/ext/protoc/protobuf/src/google/protobuf/message.cc +358 -0
  365. data/ext/protoc/protobuf/src/google/protobuf/message.h +866 -0
  366. data/ext/protoc/protobuf/src/google/protobuf/message_lite.cc +335 -0
  367. data/ext/protoc/protobuf/src/google/protobuf/message_lite.h +247 -0
  368. data/ext/protoc/protobuf/src/google/protobuf/message_unittest.cc +427 -0
  369. data/ext/protoc/protobuf/src/google/protobuf/package_info.h +64 -0
  370. data/ext/protoc/protobuf/src/google/protobuf/reflection_ops.cc +269 -0
  371. data/ext/protoc/protobuf/src/google/protobuf/reflection_ops.h +81 -0
  372. data/ext/protoc/protobuf/src/google/protobuf/reflection_ops_unittest.cc +475 -0
  373. data/ext/protoc/protobuf/src/google/protobuf/repeated_field.cc +87 -0
  374. data/ext/protoc/protobuf/src/google/protobuf/repeated_field.h +1603 -0
  375. data/ext/protoc/protobuf/src/google/protobuf/repeated_field_reflection_unittest.cc +195 -0
  376. data/ext/protoc/protobuf/src/google/protobuf/repeated_field_unittest.cc +1442 -0
  377. data/ext/protoc/protobuf/src/google/protobuf/service.cc +46 -0
  378. data/ext/protoc/protobuf/src/google/protobuf/service.h +291 -0
  379. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops.h +227 -0
  380. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h +325 -0
  381. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_arm_gcc.h +151 -0
  382. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_arm_qnx.h +146 -0
  383. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_atomicword_compat.h +122 -0
  384. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h +137 -0
  385. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_macosx.h +225 -0
  386. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_mips_gcc.h +313 -0
  387. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_pnacl.h +73 -0
  388. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_solaris.h +188 -0
  389. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_tsan.h +219 -0
  390. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc +137 -0
  391. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h +293 -0
  392. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc +112 -0
  393. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_msvc.h +150 -0
  394. data/ext/protoc/protobuf/src/google/protobuf/stubs/common.cc +395 -0
  395. data/ext/protoc/protobuf/src/google/protobuf/stubs/common.h +1226 -0
  396. data/ext/protoc/protobuf/src/google/protobuf/stubs/common_unittest.cc +357 -0
  397. data/ext/protoc/protobuf/src/google/protobuf/stubs/hash.h +232 -0
  398. data/ext/protoc/protobuf/src/google/protobuf/stubs/map_util.h +771 -0
  399. data/ext/protoc/protobuf/src/google/protobuf/stubs/once.cc +99 -0
  400. data/ext/protoc/protobuf/src/google/protobuf/stubs/once.h +166 -0
  401. data/ext/protoc/protobuf/src/google/protobuf/stubs/once_unittest.cc +253 -0
  402. data/ext/protoc/protobuf/src/google/protobuf/stubs/platform_macros.h +103 -0
  403. data/ext/protoc/protobuf/src/google/protobuf/stubs/shared_ptr.h +470 -0
  404. data/ext/protoc/protobuf/src/google/protobuf/stubs/stl_util.h +121 -0
  405. data/ext/protoc/protobuf/src/google/protobuf/stubs/stringprintf.cc +175 -0
  406. data/ext/protoc/protobuf/src/google/protobuf/stubs/stringprintf.h +76 -0
  407. data/ext/protoc/protobuf/src/google/protobuf/stubs/stringprintf_unittest.cc +152 -0
  408. data/ext/protoc/protobuf/src/google/protobuf/stubs/structurally_valid.cc +536 -0
  409. data/ext/protoc/protobuf/src/google/protobuf/stubs/structurally_valid_unittest.cc +40 -0
  410. data/ext/protoc/protobuf/src/google/protobuf/stubs/strutil.cc +1279 -0
  411. data/ext/protoc/protobuf/src/google/protobuf/stubs/strutil.h +562 -0
  412. data/ext/protoc/protobuf/src/google/protobuf/stubs/strutil_unittest.cc +73 -0
  413. data/ext/protoc/protobuf/src/google/protobuf/stubs/substitute.cc +134 -0
  414. data/ext/protoc/protobuf/src/google/protobuf/stubs/substitute.h +170 -0
  415. data/ext/protoc/protobuf/src/google/protobuf/stubs/template_util.h +138 -0
  416. data/ext/protoc/protobuf/src/google/protobuf/stubs/template_util_unittest.cc +130 -0
  417. data/ext/protoc/protobuf/src/google/protobuf/stubs/type_traits.h +336 -0
  418. data/ext/protoc/protobuf/src/google/protobuf/stubs/type_traits_unittest.cc +628 -0
  419. data/ext/protoc/protobuf/src/google/protobuf/test_util.cc +3345 -0
  420. data/ext/protoc/protobuf/src/google/protobuf/test_util.h +215 -0
  421. data/ext/protoc/protobuf/src/google/protobuf/test_util_lite.cc +1585 -0
  422. data/ext/protoc/protobuf/src/google/protobuf/test_util_lite.h +101 -0
  423. data/ext/protoc/protobuf/src/google/protobuf/testdata/bad_utf8_string +1 -0
  424. data/ext/protoc/protobuf/src/google/protobuf/testdata/golden_message +0 -0
  425. data/ext/protoc/protobuf/src/google/protobuf/testdata/golden_message_oneof_implemented +0 -0
  426. data/ext/protoc/protobuf/src/google/protobuf/testdata/golden_packed_fields_message +0 -0
  427. data/ext/protoc/protobuf/src/google/protobuf/testdata/text_format_unittest_data.txt +134 -0
  428. data/ext/protoc/protobuf/src/google/protobuf/testdata/text_format_unittest_data_oneof_implemented.txt +129 -0
  429. data/ext/protoc/protobuf/src/google/protobuf/testdata/text_format_unittest_data_pointy.txt +134 -0
  430. data/ext/protoc/protobuf/src/google/protobuf/testdata/text_format_unittest_data_pointy_oneof.txt +129 -0
  431. data/ext/protoc/protobuf/src/google/protobuf/testdata/text_format_unittest_extensions_data.txt +134 -0
  432. data/ext/protoc/protobuf/src/google/protobuf/testdata/text_format_unittest_extensions_data_pointy.txt +134 -0
  433. data/ext/protoc/protobuf/src/google/protobuf/testing/file.cc +194 -0
  434. data/ext/protoc/protobuf/src/google/protobuf/testing/file.h +97 -0
  435. data/ext/protoc/protobuf/src/google/protobuf/testing/googletest.cc +255 -0
  436. data/ext/protoc/protobuf/src/google/protobuf/testing/googletest.h +102 -0
  437. data/ext/protoc/protobuf/src/google/protobuf/testing/zcgunzip.cc +73 -0
  438. data/ext/protoc/protobuf/src/google/protobuf/testing/zcgzip.cc +79 -0
  439. data/ext/protoc/protobuf/src/google/protobuf/text_format.cc +1746 -0
  440. data/ext/protoc/protobuf/src/google/protobuf/text_format.h +473 -0
  441. data/ext/protoc/protobuf/src/google/protobuf/text_format_unittest.cc +1479 -0
  442. data/ext/protoc/protobuf/src/google/protobuf/unittest.proto +861 -0
  443. data/ext/protoc/protobuf/src/google/protobuf/unittest_custom_options.proto +393 -0
  444. data/ext/protoc/protobuf/src/google/protobuf/unittest_embed_optimize_for.proto +50 -0
  445. data/ext/protoc/protobuf/src/google/protobuf/unittest_empty.proto +37 -0
  446. data/ext/protoc/protobuf/src/google/protobuf/unittest_enormous_descriptor.proto +1046 -0
  447. data/ext/protoc/protobuf/src/google/protobuf/unittest_import.proto +64 -0
  448. data/ext/protoc/protobuf/src/google/protobuf/unittest_import_lite.proto +51 -0
  449. data/ext/protoc/protobuf/src/google/protobuf/unittest_import_public.proto +40 -0
  450. data/ext/protoc/protobuf/src/google/protobuf/unittest_import_public_lite.proto +42 -0
  451. data/ext/protoc/protobuf/src/google/protobuf/unittest_lite.proto +384 -0
  452. data/ext/protoc/protobuf/src/google/protobuf/unittest_lite_imports_nonlite.proto +43 -0
  453. data/ext/protoc/protobuf/src/google/protobuf/unittest_mset.proto +83 -0
  454. data/ext/protoc/protobuf/src/google/protobuf/unittest_no_generic_services.proto +53 -0
  455. data/ext/protoc/protobuf/src/google/protobuf/unittest_optimize_for.proto +66 -0
  456. data/ext/protoc/protobuf/src/google/protobuf/unknown_field_set.cc +265 -0
  457. data/ext/protoc/protobuf/src/google/protobuf/unknown_field_set.h +318 -0
  458. data/ext/protoc/protobuf/src/google/protobuf/unknown_field_set_unittest.cc +599 -0
  459. data/ext/protoc/protobuf/src/google/protobuf/wire_format.cc +1101 -0
  460. data/ext/protoc/protobuf/src/google/protobuf/wire_format.h +336 -0
  461. data/ext/protoc/protobuf/src/google/protobuf/wire_format_lite.cc +471 -0
  462. data/ext/protoc/protobuf/src/google/protobuf/wire_format_lite.h +661 -0
  463. data/ext/protoc/protobuf/src/google/protobuf/wire_format_lite_inl.h +860 -0
  464. data/ext/protoc/protobuf/src/google/protobuf/wire_format_unittest.cc +1120 -0
  465. data/ext/protoc/protobuf/src/solaris/libstdc++.la +51 -0
  466. data/ext/protoc/protobuf/vsprojects/config.h +29 -0
  467. data/ext/protoc/protobuf/vsprojects/convert2008to2005.sh +20 -0
  468. data/ext/protoc/protobuf/vsprojects/extract_includes.bat +50 -0
  469. data/ext/protoc/protobuf/vsprojects/libprotobuf-lite.vcproj +302 -0
  470. data/ext/protoc/protobuf/vsprojects/libprotobuf.vcproj +470 -0
  471. data/ext/protoc/protobuf/vsprojects/libprotoc.vcproj +466 -0
  472. data/ext/protoc/protobuf/vsprojects/lite-test.vcproj +305 -0
  473. data/ext/protoc/protobuf/vsprojects/protobuf.sln +92 -0
  474. data/ext/protoc/protobuf/vsprojects/protoc.vcproj +192 -0
  475. data/ext/protoc/protobuf/vsprojects/readme.txt +114 -0
  476. data/ext/protoc/protobuf/vsprojects/test_plugin.vcproj +209 -0
  477. data/ext/protoc/protobuf/vsprojects/tests.vcproj +681 -0
  478. data/lib/protoc/version.rb +1 -1
  479. metadata +480 -3
@@ -0,0 +1,140 @@
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
+ #ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__
36
+ #define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__
37
+
38
+ #include <string>
39
+ #include <map>
40
+ #include <google/protobuf/compiler/java/java_field.h>
41
+
42
+ namespace google {
43
+ namespace protobuf {
44
+ namespace compiler {
45
+ namespace java {
46
+ class Context; // context.h
47
+ class ClassNameResolver; // name_resolver.h
48
+ }
49
+ }
50
+ namespace io {
51
+ class Printer; // printer.h
52
+ }
53
+ }
54
+
55
+ namespace protobuf {
56
+ namespace compiler {
57
+ namespace java {
58
+
59
+ class MessageGenerator {
60
+ public:
61
+ explicit MessageGenerator(const Descriptor* descriptor);
62
+ virtual ~MessageGenerator();
63
+
64
+ // All static variables have to be declared at the top-level of the file
65
+ // so that we can control initialization order, which is important for
66
+ // DescriptorProto bootstrapping to work.
67
+ virtual void GenerateStaticVariables(io::Printer* printer) = 0;
68
+
69
+ // Output code which initializes the static variables generated by
70
+ // GenerateStaticVariables().
71
+ virtual void GenerateStaticVariableInitializers(io::Printer* printer) = 0;
72
+
73
+ // Generate the class itself.
74
+ virtual void Generate(io::Printer* printer) = 0;
75
+
76
+ // Generates the base interface that both the class and its builder implement
77
+ virtual void GenerateInterface(io::Printer* printer) = 0;
78
+
79
+ // Generate code to register all contained extensions with an
80
+ // ExtensionRegistry.
81
+ virtual void GenerateExtensionRegistrationCode(io::Printer* printer) = 0;
82
+
83
+ protected:
84
+ const Descriptor* descriptor_;
85
+
86
+ private:
87
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator);
88
+ };
89
+
90
+ class ImmutableMessageGenerator : public MessageGenerator {
91
+ public:
92
+ explicit ImmutableMessageGenerator(const Descriptor* descriptor,
93
+ Context* context);
94
+ virtual ~ImmutableMessageGenerator();
95
+
96
+ virtual void Generate(io::Printer* printer);
97
+ virtual void GenerateInterface(io::Printer* printer);
98
+ virtual void GenerateExtensionRegistrationCode(io::Printer* printer);
99
+ virtual void GenerateStaticVariables(io::Printer* printer);
100
+ virtual void GenerateStaticVariableInitializers(io::Printer* printer);
101
+
102
+ private:
103
+ enum UseMemoization {
104
+ MEMOIZE,
105
+ DONT_MEMOIZE
106
+ };
107
+
108
+ void GenerateFieldAccessorTable(io::Printer* printer);
109
+ void GenerateFieldAccessorTableInitializer(io::Printer* printer);
110
+
111
+ void GenerateMessageSerializationMethods(io::Printer* printer);
112
+ void GenerateParseFromMethods(io::Printer* printer);
113
+ void GenerateSerializeOneField(io::Printer* printer,
114
+ const FieldDescriptor* field);
115
+ void GenerateSerializeOneExtensionRange(
116
+ io::Printer* printer, const Descriptor::ExtensionRange* range);
117
+
118
+ void GenerateBuilder(io::Printer* printer);
119
+ void GenerateCommonBuilderMethods(io::Printer* printer);
120
+ void GenerateDescriptorMethods(io::Printer* printer);
121
+ void GenerateBuilderParsingMethods(io::Printer* printer);
122
+ void GenerateIsInitialized(io::Printer* printer,
123
+ UseMemoization useMemoization);
124
+ void GenerateEqualsAndHashCode(io::Printer* printer);
125
+ void GenerateParser(io::Printer* printer);
126
+ void GenerateParsingConstructor(io::Printer* printer);
127
+
128
+ Context* context_;
129
+ ClassNameResolver* name_resolver_;
130
+ FieldGeneratorMap<ImmutableFieldGenerator> field_generators_;
131
+
132
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageGenerator);
133
+ };
134
+
135
+ } // namespace java
136
+ } // namespace compiler
137
+ } // namespace protobuf
138
+
139
+ } // namespace google
140
+ #endif // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__
@@ -0,0 +1,1343 @@
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/compiler/java/java_context.h>
39
+ #include <google/protobuf/compiler/java/java_message_field.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/io/printer.h>
44
+ #include <google/protobuf/wire_format.h>
45
+ #include <google/protobuf/stubs/strutil.h>
46
+
47
+ namespace google {
48
+ namespace protobuf {
49
+ namespace compiler {
50
+ namespace java {
51
+
52
+ namespace {
53
+
54
+ void SetMessageVariables(const FieldDescriptor* descriptor,
55
+ int messageBitIndex,
56
+ int builderBitIndex,
57
+ const FieldGeneratorInfo* info,
58
+ ClassNameResolver* name_resolver,
59
+ map<string, string>* variables) {
60
+ SetCommonFieldVariables(descriptor, info, variables);
61
+
62
+ (*variables)["type"] =
63
+ name_resolver->GetImmutableClassName(descriptor->message_type());
64
+ (*variables)["mutable_type"] =
65
+ name_resolver->GetMutableClassName(descriptor->message_type());
66
+ (*variables)["group_or_message"] =
67
+ (GetType(descriptor) == FieldDescriptor::TYPE_GROUP) ?
68
+ "Group" : "Message";
69
+ // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
70
+ // by the proto compiler
71
+ (*variables)["deprecation"] = descriptor->options().deprecated()
72
+ ? "@java.lang.Deprecated " : "";
73
+ (*variables)["on_changed"] =
74
+ HasDescriptorMethods(descriptor->containing_type()) ? "onChanged();" : "";
75
+
76
+ if (SupportFieldPresence(descriptor->file())) {
77
+ // For singular messages and builders, one bit is used for the hasField bit.
78
+ (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex);
79
+ (*variables)["get_has_field_bit_builder"] = GenerateGetBit(builderBitIndex);
80
+
81
+ // Note that these have a trailing ";".
82
+ (*variables)["set_has_field_bit_message"] =
83
+ GenerateSetBit(messageBitIndex) + ";";
84
+ (*variables)["set_has_field_bit_builder"] =
85
+ GenerateSetBit(builderBitIndex) + ";";
86
+ (*variables)["clear_has_field_bit_builder"] =
87
+ GenerateClearBit(builderBitIndex) + ";";
88
+
89
+ (*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex);
90
+ } else {
91
+ (*variables)["set_has_field_bit_message"] = "";
92
+ (*variables)["set_has_field_bit_builder"] = "";
93
+ (*variables)["clear_has_field_bit_builder"] = "";
94
+
95
+ (*variables)["is_field_present_message"] =
96
+ (*variables)["name"] + "_ != null";
97
+ }
98
+
99
+ // For repated builders, one bit is used for whether the array is immutable.
100
+ (*variables)["get_mutable_bit_builder"] = GenerateGetBit(builderBitIndex);
101
+ (*variables)["set_mutable_bit_builder"] = GenerateSetBit(builderBitIndex);
102
+ (*variables)["clear_mutable_bit_builder"] = GenerateClearBit(builderBitIndex);
103
+
104
+ // For repeated fields, one bit is used for whether the array is immutable
105
+ // in the parsing constructor.
106
+ (*variables)["get_mutable_bit_parser"] =
107
+ GenerateGetBitMutableLocal(builderBitIndex);
108
+ (*variables)["set_mutable_bit_parser"] =
109
+ GenerateSetBitMutableLocal(builderBitIndex);
110
+
111
+ (*variables)["get_has_field_bit_from_local"] =
112
+ GenerateGetBitFromLocal(builderBitIndex);
113
+ (*variables)["set_has_field_bit_to_local"] =
114
+ GenerateSetBitToLocal(messageBitIndex);
115
+ }
116
+
117
+ } // namespace
118
+
119
+ // ===================================================================
120
+
121
+ ImmutableMessageFieldGenerator::
122
+ ImmutableMessageFieldGenerator(const FieldDescriptor* descriptor,
123
+ int messageBitIndex,
124
+ int builderBitIndex,
125
+ Context* context)
126
+ : descriptor_(descriptor), messageBitIndex_(messageBitIndex),
127
+ builderBitIndex_(builderBitIndex), context_(context),
128
+ name_resolver_(context->GetNameResolver()) {
129
+ SetMessageVariables(descriptor, messageBitIndex, builderBitIndex,
130
+ context->GetFieldGeneratorInfo(descriptor),
131
+ name_resolver_, &variables_);
132
+ }
133
+
134
+ ImmutableMessageFieldGenerator::~ImmutableMessageFieldGenerator() {}
135
+
136
+ int ImmutableMessageFieldGenerator::GetNumBitsForMessage() const {
137
+ return 1;
138
+ }
139
+
140
+ int ImmutableMessageFieldGenerator::GetNumBitsForBuilder() const {
141
+ return 1;
142
+ }
143
+
144
+ void ImmutableMessageFieldGenerator::
145
+ GenerateInterfaceMembers(io::Printer* printer) const {
146
+ // TODO(jonp): In the future, consider having a method specific to the
147
+ // interface so that builders can choose dynamically to either return a
148
+ // message or a nested builder, so that asking for the interface doesn't
149
+ // cause a message to ever be built.
150
+ if (SupportFieldPresence(descriptor_->file()) ||
151
+ descriptor_->containing_oneof() == NULL) {
152
+ WriteFieldDocComment(printer, descriptor_);
153
+ printer->Print(variables_,
154
+ "$deprecation$boolean has$capitalized_name$();\n");
155
+ }
156
+ WriteFieldDocComment(printer, descriptor_);
157
+ printer->Print(variables_,
158
+ "$deprecation$$type$ get$capitalized_name$();\n");
159
+
160
+ if (HasNestedBuilders(descriptor_->containing_type())) {
161
+ WriteFieldDocComment(printer, descriptor_);
162
+ printer->Print(variables_,
163
+ "$deprecation$$type$OrBuilder get$capitalized_name$OrBuilder();\n");
164
+ }
165
+ }
166
+
167
+ void ImmutableMessageFieldGenerator::
168
+ GenerateMembers(io::Printer* printer) const {
169
+ printer->Print(variables_,
170
+ "private $type$ $name$_;\n");
171
+ PrintExtraFieldInfo(variables_, printer);
172
+
173
+ if (SupportFieldPresence(descriptor_->file())) {
174
+ WriteFieldDocComment(printer, descriptor_);
175
+ printer->Print(variables_,
176
+ "$deprecation$public boolean has$capitalized_name$() {\n"
177
+ " return $get_has_field_bit_message$;\n"
178
+ "}\n");
179
+ WriteFieldDocComment(printer, descriptor_);
180
+ printer->Print(variables_,
181
+ "$deprecation$public $type$ get$capitalized_name$() {\n"
182
+ " return $name$_;\n"
183
+ "}\n");
184
+
185
+ if (HasNestedBuilders(descriptor_->containing_type())) {
186
+ WriteFieldDocComment(printer, descriptor_);
187
+ printer->Print(variables_,
188
+ "$deprecation$public $type$OrBuilder "
189
+ "get$capitalized_name$OrBuilder() {\n"
190
+ " return $name$_;\n"
191
+ "}\n");
192
+ }
193
+ } else {
194
+ WriteFieldDocComment(printer, descriptor_);
195
+ printer->Print(variables_,
196
+ "$deprecation$public boolean has$capitalized_name$() {\n"
197
+ " return $name$_ != null;\n"
198
+ "}\n");
199
+ WriteFieldDocComment(printer, descriptor_);
200
+ printer->Print(variables_,
201
+ "$deprecation$public $type$ get$capitalized_name$() {\n"
202
+ " return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n"
203
+ "}\n");
204
+
205
+ if (HasNestedBuilders(descriptor_->containing_type())) {
206
+ WriteFieldDocComment(printer, descriptor_);
207
+ printer->Print(variables_,
208
+ "$deprecation$public $type$OrBuilder "
209
+ "get$capitalized_name$OrBuilder() {\n"
210
+ " return get$capitalized_name$();\n"
211
+ "}\n");
212
+ }
213
+ }
214
+ }
215
+
216
+ void ImmutableMessageFieldGenerator::PrintNestedBuilderCondition(
217
+ io::Printer* printer,
218
+ const char* regular_case,
219
+ const char* nested_builder_case) const {
220
+ if (HasNestedBuilders(descriptor_->containing_type())) {
221
+ printer->Print(variables_, "if ($name$Builder_ == null) {\n");
222
+ printer->Indent();
223
+ printer->Print(variables_, regular_case);
224
+ printer->Outdent();
225
+ printer->Print("} else {\n");
226
+ printer->Indent();
227
+ printer->Print(variables_, nested_builder_case);
228
+ printer->Outdent();
229
+ printer->Print("}\n");
230
+ } else {
231
+ printer->Print(variables_, regular_case);
232
+ }
233
+ }
234
+
235
+ void ImmutableMessageFieldGenerator::PrintNestedBuilderFunction(
236
+ io::Printer* printer,
237
+ const char* method_prototype,
238
+ const char* regular_case,
239
+ const char* nested_builder_case,
240
+ const char* trailing_code) const {
241
+ printer->Print(variables_, method_prototype);
242
+ printer->Print(" {\n");
243
+ printer->Indent();
244
+ PrintNestedBuilderCondition(printer, regular_case, nested_builder_case);
245
+ if (trailing_code != NULL) {
246
+ printer->Print(variables_, trailing_code);
247
+ }
248
+ printer->Outdent();
249
+ printer->Print("}\n");
250
+ }
251
+
252
+ void ImmutableMessageFieldGenerator::
253
+ GenerateBuilderMembers(io::Printer* printer) const {
254
+ // When using nested-builders, the code initially works just like the
255
+ // non-nested builder case. It only creates a nested builder lazily on
256
+ // demand and then forever delegates to it after creation.
257
+
258
+ bool support_field_presence = SupportFieldPresence(descriptor_->file());
259
+
260
+ if (support_field_presence) {
261
+ printer->Print(variables_,
262
+ // Used when the builder is null.
263
+ "private $type$ $name$_ = $type$.getDefaultInstance();\n");
264
+ } else {
265
+ printer->Print(variables_,
266
+ "private $type$ $name$_ = null;\n");
267
+ }
268
+
269
+ if (HasNestedBuilders(descriptor_->containing_type())) {
270
+ printer->Print(variables_,
271
+ // If this builder is non-null, it is used and the other fields are
272
+ // ignored.
273
+ "private com.google.protobuf.SingleFieldBuilder<\n"
274
+ " $type$, $type$.Builder, $type$OrBuilder> $name$Builder_;"
275
+ "\n");
276
+ }
277
+
278
+ // The comments above the methods below are based on a hypothetical
279
+ // field of type "Field" called "Field".
280
+
281
+ // boolean hasField()
282
+ WriteFieldDocComment(printer, descriptor_);
283
+ if (support_field_presence) {
284
+ printer->Print(variables_,
285
+ "$deprecation$public boolean has$capitalized_name$() {\n"
286
+ " return $get_has_field_bit_builder$;\n"
287
+ "}\n");
288
+ } else {
289
+ printer->Print(variables_,
290
+ "$deprecation$public boolean has$capitalized_name$() {\n"
291
+ " return $name$Builder_ != null || $name$_ != null;\n"
292
+ "}\n");
293
+ }
294
+
295
+ // Field getField()
296
+ WriteFieldDocComment(printer, descriptor_);
297
+ PrintNestedBuilderFunction(printer,
298
+ "$deprecation$public $type$ get$capitalized_name$()",
299
+
300
+ support_field_presence
301
+ ? "return $name$_;\n"
302
+ : "return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\n",
303
+
304
+ "return $name$Builder_.getMessage();\n",
305
+
306
+ NULL);
307
+
308
+ // Field.Builder setField(Field value)
309
+ WriteFieldDocComment(printer, descriptor_);
310
+ PrintNestedBuilderFunction(printer,
311
+ "$deprecation$public Builder set$capitalized_name$($type$ value)",
312
+
313
+ "if (value == null) {\n"
314
+ " throw new NullPointerException();\n"
315
+ "}\n"
316
+ "$name$_ = value;\n"
317
+ "$on_changed$\n",
318
+
319
+ "$name$Builder_.setMessage(value);\n",
320
+
321
+ "$set_has_field_bit_builder$\n"
322
+ "return this;\n");
323
+
324
+ // Field.Builder setField(Field.Builder builderForValue)
325
+ WriteFieldDocComment(printer, descriptor_);
326
+ PrintNestedBuilderFunction(printer,
327
+ "$deprecation$public Builder set$capitalized_name$(\n"
328
+ " $type$.Builder builderForValue)",
329
+
330
+ "$name$_ = builderForValue.build();\n"
331
+ "$on_changed$\n",
332
+
333
+ "$name$Builder_.setMessage(builderForValue.build());\n",
334
+
335
+ "$set_has_field_bit_builder$\n"
336
+ "return this;\n");
337
+
338
+ // Field.Builder mergeField(Field value)
339
+ WriteFieldDocComment(printer, descriptor_);
340
+ PrintNestedBuilderFunction(printer,
341
+ "$deprecation$public Builder merge$capitalized_name$($type$ value)",
342
+
343
+ support_field_presence
344
+ ? "if ($get_has_field_bit_builder$ &&\n"
345
+ " $name$_ != $type$.getDefaultInstance()) {\n"
346
+ " $name$_ =\n"
347
+ " $type$.newBuilder($name$_).mergeFrom(value).buildPartial();\n"
348
+ "} else {\n"
349
+ " $name$_ = value;\n"
350
+ "}\n"
351
+ "$on_changed$\n"
352
+ : "if ($name$_ != null) {\n"
353
+ " $name$_ =\n"
354
+ " $type$.newBuilder($name$_).mergeFrom(value).buildPartial();\n"
355
+ "} else {\n"
356
+ " $name$_ = value;\n"
357
+ "}\n"
358
+ "$on_changed$\n",
359
+
360
+ "$name$Builder_.mergeFrom(value);\n",
361
+
362
+ "$set_has_field_bit_builder$\n"
363
+ "return this;\n");
364
+
365
+ // Field.Builder clearField()
366
+ WriteFieldDocComment(printer, descriptor_);
367
+ PrintNestedBuilderFunction(printer,
368
+ "$deprecation$public Builder clear$capitalized_name$()",
369
+
370
+ support_field_presence
371
+ ? "$name$_ = $type$.getDefaultInstance();\n"
372
+ "$on_changed$\n"
373
+ : "$name$_ = null;\n"
374
+ "$on_changed$\n",
375
+
376
+ support_field_presence
377
+ ? "$name$Builder_.clear();\n"
378
+ : "$name$_ = null;\n"
379
+ "$name$Builder_ = null;\n",
380
+
381
+ "$clear_has_field_bit_builder$\n"
382
+ "return this;\n");
383
+
384
+ if (HasNestedBuilders(descriptor_->containing_type())) {
385
+ WriteFieldDocComment(printer, descriptor_);
386
+ printer->Print(variables_,
387
+ "$deprecation$public $type$.Builder get$capitalized_name$Builder() {\n"
388
+ " $set_has_field_bit_builder$\n"
389
+ " $on_changed$\n"
390
+ " return get$capitalized_name$FieldBuilder().getBuilder();\n"
391
+ "}\n");
392
+ WriteFieldDocComment(printer, descriptor_);
393
+ printer->Print(variables_,
394
+ "$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder() {\n"
395
+ " if ($name$Builder_ != null) {\n"
396
+ " return $name$Builder_.getMessageOrBuilder();\n"
397
+ " } else {\n");
398
+ if (support_field_presence) {
399
+ printer->Print(variables_,
400
+ " return $name$_;\n");
401
+ } else {
402
+ printer->Print(variables_,
403
+ " return $name$_ == null ?\n"
404
+ " $type$.getDefaultInstance() : $name$_;\n");
405
+ }
406
+ printer->Print(variables_,
407
+ " }\n"
408
+ "}\n");
409
+ WriteFieldDocComment(printer, descriptor_);
410
+ printer->Print(variables_,
411
+ "private com.google.protobuf.SingleFieldBuilder<\n"
412
+ " $type$, $type$.Builder, $type$OrBuilder> \n"
413
+ " get$capitalized_name$FieldBuilder() {\n"
414
+ " if ($name$Builder_ == null) {\n"
415
+ " $name$Builder_ = new com.google.protobuf.SingleFieldBuilder<\n"
416
+ " $type$, $type$.Builder, $type$OrBuilder>(\n"
417
+ " get$capitalized_name$(),\n"
418
+ " getParentForChildren(),\n"
419
+ " isClean());\n"
420
+ " $name$_ = null;\n"
421
+ " }\n"
422
+ " return $name$Builder_;\n"
423
+ "}\n");
424
+ }
425
+ }
426
+
427
+ void ImmutableMessageFieldGenerator::
428
+ GenerateFieldBuilderInitializationCode(io::Printer* printer) const {
429
+ if (SupportFieldPresence(descriptor_->file())) {
430
+ printer->Print(variables_,
431
+ "get$capitalized_name$FieldBuilder();\n");
432
+ }
433
+ }
434
+
435
+
436
+ void ImmutableMessageFieldGenerator::
437
+ GenerateInitializationCode(io::Printer* printer) const {
438
+ if (SupportFieldPresence(descriptor_->file())) {
439
+ printer->Print(variables_, "$name$_ = $type$.getDefaultInstance();\n");
440
+ }
441
+ }
442
+
443
+ void ImmutableMessageFieldGenerator::
444
+ GenerateBuilderClearCode(io::Printer* printer) const {
445
+ if (SupportFieldPresence(descriptor_->file())) {
446
+ PrintNestedBuilderCondition(printer,
447
+ "$name$_ = $type$.getDefaultInstance();\n",
448
+
449
+ "$name$Builder_.clear();\n");
450
+ printer->Print(variables_, "$clear_has_field_bit_builder$\n");
451
+ } else {
452
+ PrintNestedBuilderCondition(printer,
453
+ "$name$_ = null;\n",
454
+
455
+ "$name$_ = null;\n"
456
+ "$name$Builder_ = null;\n");
457
+ }
458
+ }
459
+
460
+ void ImmutableMessageFieldGenerator::
461
+ GenerateMergingCode(io::Printer* printer) const {
462
+ printer->Print(variables_,
463
+ "if (other.has$capitalized_name$()) {\n"
464
+ " merge$capitalized_name$(other.get$capitalized_name$());\n"
465
+ "}\n");
466
+ }
467
+
468
+ void ImmutableMessageFieldGenerator::
469
+ GenerateBuildingCode(io::Printer* printer) const {
470
+ if (SupportFieldPresence(descriptor_->file())) {
471
+ printer->Print(variables_,
472
+ "if ($get_has_field_bit_from_local$) {\n"
473
+ " $set_has_field_bit_to_local$;\n"
474
+ "}\n");
475
+ }
476
+
477
+ PrintNestedBuilderCondition(printer,
478
+ "result.$name$_ = $name$_;\n",
479
+
480
+ "result.$name$_ = $name$Builder_.build();\n");
481
+ }
482
+
483
+ void ImmutableMessageFieldGenerator::
484
+ GenerateParsingCode(io::Printer* printer) const {
485
+ printer->Print(variables_,
486
+ "$type$.Builder subBuilder = null;\n"
487
+ "if ($is_field_present_message$) {\n"
488
+ " subBuilder = $name$_.toBuilder();\n"
489
+ "}\n");
490
+
491
+ if (GetType(descriptor_) == FieldDescriptor::TYPE_GROUP) {
492
+ printer->Print(variables_,
493
+ "$name$_ = input.readGroup($number$, $type$.PARSER,\n"
494
+ " extensionRegistry);\n");
495
+ } else {
496
+ printer->Print(variables_,
497
+ "$name$_ = input.readMessage($type$.PARSER, extensionRegistry);\n");
498
+ }
499
+
500
+ printer->Print(variables_,
501
+ "if (subBuilder != null) {\n"
502
+ " subBuilder.mergeFrom($name$_);\n"
503
+ " $name$_ = subBuilder.buildPartial();\n"
504
+ "}\n"
505
+ "$set_has_field_bit_message$\n");
506
+ }
507
+
508
+ void ImmutableMessageFieldGenerator::
509
+ GenerateParsingDoneCode(io::Printer* printer) const {
510
+ // noop for messages.
511
+ }
512
+
513
+ void ImmutableMessageFieldGenerator::
514
+ GenerateSerializationCode(io::Printer* printer) const {
515
+ printer->Print(variables_,
516
+ "if ($is_field_present_message$) {\n"
517
+ " output.write$group_or_message$($number$, $name$_);\n"
518
+ "}\n");
519
+ }
520
+
521
+ void ImmutableMessageFieldGenerator::
522
+ GenerateSerializedSizeCode(io::Printer* printer) const {
523
+ printer->Print(variables_,
524
+ "if ($is_field_present_message$) {\n"
525
+ " size += com.google.protobuf.CodedOutputStream\n"
526
+ " .compute$group_or_message$Size($number$, $name$_);\n"
527
+ "}\n");
528
+ }
529
+
530
+ void ImmutableMessageFieldGenerator::
531
+ GenerateEqualsCode(io::Printer* printer) const {
532
+ printer->Print(variables_,
533
+ "result = result && get$capitalized_name$()\n"
534
+ " .equals(other.get$capitalized_name$());\n");
535
+ }
536
+
537
+ void ImmutableMessageFieldGenerator::
538
+ GenerateHashCode(io::Printer* printer) const {
539
+ printer->Print(variables_,
540
+ "hash = (37 * hash) + $constant_name$;\n"
541
+ "hash = (53 * hash) + get$capitalized_name$().hashCode();\n");
542
+ }
543
+
544
+ string ImmutableMessageFieldGenerator::GetBoxedType() const {
545
+ return name_resolver_->GetImmutableClassName(descriptor_->message_type());
546
+ }
547
+
548
+ // ===================================================================
549
+
550
+ ImmutableMessageOneofFieldGenerator::
551
+ ImmutableMessageOneofFieldGenerator(const FieldDescriptor* descriptor,
552
+ int messageBitIndex,
553
+ int builderBitIndex,
554
+ Context* context)
555
+ : ImmutableMessageFieldGenerator(
556
+ descriptor, messageBitIndex, builderBitIndex, context) {
557
+ const OneofGeneratorInfo* info =
558
+ context->GetOneofGeneratorInfo(descriptor->containing_oneof());
559
+ SetCommonOneofVariables(descriptor, info, &variables_);
560
+ }
561
+
562
+ ImmutableMessageOneofFieldGenerator::
563
+ ~ImmutableMessageOneofFieldGenerator() {}
564
+
565
+ void ImmutableMessageOneofFieldGenerator::
566
+ GenerateMembers(io::Printer* printer) const {
567
+ PrintExtraFieldInfo(variables_, printer);
568
+ if (SupportFieldPresence(descriptor_->file())) {
569
+ WriteFieldDocComment(printer, descriptor_);
570
+ printer->Print(variables_,
571
+ "$deprecation$public boolean has$capitalized_name$() {\n"
572
+ " return $has_oneof_case_message$;\n"
573
+ "}\n");
574
+ }
575
+ WriteFieldDocComment(printer, descriptor_);
576
+ printer->Print(variables_,
577
+ "$deprecation$public $type$ get$capitalized_name$() {\n"
578
+ " if ($has_oneof_case_message$) {\n"
579
+ " return ($type$) $oneof_name$_;\n"
580
+ " }\n"
581
+ " return $type$.getDefaultInstance();\n"
582
+ "}\n");
583
+
584
+ if (HasNestedBuilders(descriptor_->containing_type())) {
585
+ WriteFieldDocComment(printer, descriptor_);
586
+ printer->Print(variables_,
587
+ "$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder() {\n"
588
+ " if ($has_oneof_case_message$) {\n"
589
+ " return ($type$) $oneof_name$_;\n"
590
+ " }\n"
591
+ " return $type$.getDefaultInstance();\n"
592
+ "}\n");
593
+ }
594
+ }
595
+
596
+ void ImmutableMessageOneofFieldGenerator::
597
+ GenerateBuilderMembers(io::Printer* printer) const {
598
+ // When using nested-builders, the code initially works just like the
599
+ // non-nested builder case. It only creates a nested builder lazily on
600
+ // demand and then forever delegates to it after creation.
601
+ if (HasNestedBuilders(descriptor_->containing_type())) {
602
+ printer->Print(variables_,
603
+ // If this builder is non-null, it is used and the other fields are
604
+ // ignored.
605
+ "private com.google.protobuf.SingleFieldBuilder<\n"
606
+ " $type$, $type$.Builder, $type$OrBuilder> $name$Builder_;"
607
+ "\n");
608
+ }
609
+
610
+ // The comments above the methods below are based on a hypothetical
611
+ // field of type "Field" called "Field".
612
+
613
+ if (SupportFieldPresence(descriptor_->file())) {
614
+ // boolean hasField()
615
+ WriteFieldDocComment(printer, descriptor_);
616
+ printer->Print(variables_,
617
+ "$deprecation$public boolean has$capitalized_name$() {\n"
618
+ " return $has_oneof_case_message$;\n"
619
+ "}\n");
620
+ }
621
+
622
+ // Field getField()
623
+ WriteFieldDocComment(printer, descriptor_);
624
+ PrintNestedBuilderFunction(printer,
625
+ "$deprecation$public $type$ get$capitalized_name$()",
626
+
627
+ "if ($has_oneof_case_message$) {\n"
628
+ " return ($type$) $oneof_name$_;\n"
629
+ "}\n"
630
+ "return $type$.getDefaultInstance();\n",
631
+
632
+ "if ($has_oneof_case_message$) {\n"
633
+ " return $name$Builder_.getMessage();\n"
634
+ "}\n"
635
+ "return $type$.getDefaultInstance();\n",
636
+
637
+ NULL);
638
+
639
+ // Field.Builder setField(Field value)
640
+ WriteFieldDocComment(printer, descriptor_);
641
+ PrintNestedBuilderFunction(printer,
642
+ "$deprecation$public Builder set$capitalized_name$($type$ value)",
643
+
644
+ "if (value == null) {\n"
645
+ " throw new NullPointerException();\n"
646
+ "}\n"
647
+ "$oneof_name$_ = value;\n"
648
+ "$on_changed$\n",
649
+
650
+ "$name$Builder_.setMessage(value);\n",
651
+
652
+ "$set_oneof_case_message$;\n"
653
+ "return this;\n");
654
+
655
+ // Field.Builder setField(Field.Builder builderForValue)
656
+ WriteFieldDocComment(printer, descriptor_);
657
+ PrintNestedBuilderFunction(printer,
658
+ "$deprecation$public Builder set$capitalized_name$(\n"
659
+ " $type$.Builder builderForValue)",
660
+
661
+ "$oneof_name$_ = builderForValue.build();\n"
662
+ "$on_changed$\n",
663
+
664
+ "$name$Builder_.setMessage(builderForValue.build());\n",
665
+
666
+ "$set_oneof_case_message$;\n"
667
+ "return this;\n");
668
+
669
+ // Field.Builder mergeField(Field value)
670
+ WriteFieldDocComment(printer, descriptor_);
671
+ PrintNestedBuilderFunction(printer,
672
+ "$deprecation$public Builder merge$capitalized_name$($type$ value)",
673
+
674
+ "if ($has_oneof_case_message$ &&\n"
675
+ " $oneof_name$_ != $type$.getDefaultInstance()) {\n"
676
+ " $oneof_name$_ = $type$.newBuilder(($type$) $oneof_name$_)\n"
677
+ " .mergeFrom(value).buildPartial();\n"
678
+ "} else {\n"
679
+ " $oneof_name$_ = value;\n"
680
+ "}\n"
681
+ "$on_changed$\n",
682
+
683
+ "if ($has_oneof_case_message$) {\n"
684
+ " $name$Builder_.mergeFrom(value);\n"
685
+ "}\n"
686
+ "$name$Builder_.setMessage(value);\n",
687
+
688
+ "$set_oneof_case_message$;\n"
689
+ "return this;\n");
690
+
691
+ // Field.Builder clearField()
692
+ WriteFieldDocComment(printer, descriptor_);
693
+ PrintNestedBuilderFunction(printer,
694
+ "$deprecation$public Builder clear$capitalized_name$()",
695
+
696
+ "if ($has_oneof_case_message$) {\n"
697
+ " $clear_oneof_case_message$;\n"
698
+ " $oneof_name$_ = null;\n"
699
+ " $on_changed$\n"
700
+ "}\n",
701
+
702
+ "if ($has_oneof_case_message$) {\n"
703
+ " $clear_oneof_case_message$;\n"
704
+ " $oneof_name$_ = null;\n"
705
+ "}\n"
706
+ "$name$Builder_.clear();\n",
707
+
708
+ "return this;\n");
709
+
710
+ if (HasNestedBuilders(descriptor_->containing_type())) {
711
+ WriteFieldDocComment(printer, descriptor_);
712
+ printer->Print(variables_,
713
+ "$deprecation$public $type$.Builder get$capitalized_name$Builder() {\n"
714
+ " return get$capitalized_name$FieldBuilder().getBuilder();\n"
715
+ "}\n");
716
+ WriteFieldDocComment(printer, descriptor_);
717
+ printer->Print(variables_,
718
+ "$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder() {\n"
719
+ " if (($has_oneof_case_message$) && ($name$Builder_ != null)) {\n"
720
+ " return $name$Builder_.getMessageOrBuilder();\n"
721
+ " } else {\n"
722
+ " if ($has_oneof_case_message$) {\n"
723
+ " return ($type$) $oneof_name$_;\n"
724
+ " }\n"
725
+ " return $type$.getDefaultInstance();\n"
726
+ " }\n"
727
+ "}\n");
728
+ WriteFieldDocComment(printer, descriptor_);
729
+ printer->Print(variables_,
730
+ "private com.google.protobuf.SingleFieldBuilder<\n"
731
+ " $type$, $type$.Builder, $type$OrBuilder> \n"
732
+ " get$capitalized_name$FieldBuilder() {\n"
733
+ " if ($name$Builder_ == null) {\n"
734
+ " if (!($has_oneof_case_message$)) {\n"
735
+ " $oneof_name$_ = $type$.getDefaultInstance();\n"
736
+ " }\n"
737
+ " $name$Builder_ = new com.google.protobuf.SingleFieldBuilder<\n"
738
+ " $type$, $type$.Builder, $type$OrBuilder>(\n"
739
+ " ($type$) $oneof_name$_,\n"
740
+ " getParentForChildren(),\n"
741
+ " isClean());\n"
742
+ " $oneof_name$_ = null;\n"
743
+ " }\n"
744
+ " $set_oneof_case_message$;\n"
745
+ " return $name$Builder_;\n"
746
+ "}\n");
747
+ }
748
+ }
749
+
750
+ void ImmutableMessageOneofFieldGenerator::
751
+ GenerateBuildingCode(io::Printer* printer) const {
752
+
753
+ printer->Print(variables_,
754
+ "if ($has_oneof_case_message$) {\n");
755
+ printer->Indent();
756
+
757
+ PrintNestedBuilderCondition(printer,
758
+ "result.$oneof_name$_ = $oneof_name$_;\n",
759
+
760
+ "result.$oneof_name$_ = $name$Builder_.build();\n");
761
+
762
+ printer->Outdent();
763
+ printer->Print("}\n");
764
+ }
765
+
766
+ void ImmutableMessageOneofFieldGenerator::
767
+ GenerateMergingCode(io::Printer* printer) const {
768
+ printer->Print(variables_,
769
+ "merge$capitalized_name$(other.get$capitalized_name$());\n");
770
+ }
771
+
772
+ void ImmutableMessageOneofFieldGenerator::
773
+ GenerateParsingCode(io::Printer* printer) const {
774
+ printer->Print(variables_,
775
+ "$type$.Builder subBuilder = null;\n"
776
+ "if ($has_oneof_case_message$) {\n"
777
+ " subBuilder = (($type$) $oneof_name$_).toBuilder();\n"
778
+ "}\n");
779
+
780
+ if (GetType(descriptor_) == FieldDescriptor::TYPE_GROUP) {
781
+ printer->Print(variables_,
782
+ "$oneof_name$_ = input.readGroup($number$, $type$.PARSER,\n"
783
+ " extensionRegistry);\n");
784
+ } else {
785
+ printer->Print(variables_,
786
+ "$oneof_name$_ = input.readMessage($type$.PARSER, extensionRegistry);\n");
787
+ }
788
+
789
+ printer->Print(variables_,
790
+ "if (subBuilder != null) {\n"
791
+ " subBuilder.mergeFrom(($type$) $oneof_name$_);\n"
792
+ " $oneof_name$_ = subBuilder.buildPartial();\n"
793
+ "}\n");
794
+ printer->Print(variables_,
795
+ "$set_oneof_case_message$;\n");
796
+ }
797
+
798
+ void ImmutableMessageOneofFieldGenerator::
799
+ GenerateSerializationCode(io::Printer* printer) const {
800
+ printer->Print(variables_,
801
+ "if ($has_oneof_case_message$) {\n"
802
+ " output.write$group_or_message$($number$, ($type$) $oneof_name$_);\n"
803
+ "}\n");
804
+ }
805
+
806
+ void ImmutableMessageOneofFieldGenerator::
807
+ GenerateSerializedSizeCode(io::Printer* printer) const {
808
+ printer->Print(variables_,
809
+ "if ($has_oneof_case_message$) {\n"
810
+ " size += com.google.protobuf.CodedOutputStream\n"
811
+ " .compute$group_or_message$Size($number$, ($type$) $oneof_name$_);\n"
812
+ "}\n");
813
+ }
814
+
815
+ // ===================================================================
816
+
817
+ RepeatedImmutableMessageFieldGenerator::
818
+ RepeatedImmutableMessageFieldGenerator(const FieldDescriptor* descriptor,
819
+ int messageBitIndex,
820
+ int builderBitIndex,
821
+ Context* context)
822
+ : descriptor_(descriptor), messageBitIndex_(messageBitIndex),
823
+ builderBitIndex_(builderBitIndex), context_(context),
824
+ name_resolver_(context->GetNameResolver()) {
825
+ SetMessageVariables(descriptor, messageBitIndex, builderBitIndex,
826
+ context->GetFieldGeneratorInfo(descriptor),
827
+ name_resolver_, &variables_);
828
+ }
829
+
830
+ RepeatedImmutableMessageFieldGenerator::
831
+ ~RepeatedImmutableMessageFieldGenerator() {}
832
+
833
+ int RepeatedImmutableMessageFieldGenerator::GetNumBitsForMessage() const {
834
+ return 0;
835
+ }
836
+
837
+ int RepeatedImmutableMessageFieldGenerator::GetNumBitsForBuilder() const {
838
+ return 1;
839
+ }
840
+
841
+ void RepeatedImmutableMessageFieldGenerator::
842
+ GenerateInterfaceMembers(io::Printer* printer) const {
843
+ // TODO(jonp): In the future, consider having methods specific to the
844
+ // interface so that builders can choose dynamically to either return a
845
+ // message or a nested builder, so that asking for the interface doesn't
846
+ // cause a message to ever be built.
847
+ WriteFieldDocComment(printer, descriptor_);
848
+ printer->Print(variables_,
849
+ "$deprecation$java.util.List<$type$> \n"
850
+ " get$capitalized_name$List();\n");
851
+ WriteFieldDocComment(printer, descriptor_);
852
+ printer->Print(variables_,
853
+ "$deprecation$$type$ get$capitalized_name$(int index);\n");
854
+ WriteFieldDocComment(printer, descriptor_);
855
+ printer->Print(variables_,
856
+ "$deprecation$int get$capitalized_name$Count();\n");
857
+ if (HasNestedBuilders(descriptor_->containing_type())) {
858
+ WriteFieldDocComment(printer, descriptor_);
859
+ printer->Print(variables_,
860
+ "$deprecation$java.util.List<? extends $type$OrBuilder> \n"
861
+ " get$capitalized_name$OrBuilderList();\n");
862
+ WriteFieldDocComment(printer, descriptor_);
863
+ printer->Print(variables_,
864
+ "$deprecation$$type$OrBuilder get$capitalized_name$OrBuilder(\n"
865
+ " int index);\n");
866
+ }
867
+ }
868
+
869
+ void RepeatedImmutableMessageFieldGenerator::
870
+ GenerateMembers(io::Printer* printer) const {
871
+ printer->Print(variables_,
872
+ "private java.util.List<$type$> $name$_;\n");
873
+ PrintExtraFieldInfo(variables_, printer);
874
+ WriteFieldDocComment(printer, descriptor_);
875
+ printer->Print(variables_,
876
+ "$deprecation$public java.util.List<$type$> get$capitalized_name$List() {\n"
877
+ " return $name$_;\n" // note: unmodifiable list
878
+ "}\n");
879
+ WriteFieldDocComment(printer, descriptor_);
880
+ printer->Print(variables_,
881
+ "$deprecation$public java.util.List<? extends $type$OrBuilder> \n"
882
+ " get$capitalized_name$OrBuilderList() {\n"
883
+ " return $name$_;\n"
884
+ "}\n");
885
+ WriteFieldDocComment(printer, descriptor_);
886
+ printer->Print(variables_,
887
+ "$deprecation$public int get$capitalized_name$Count() {\n"
888
+ " return $name$_.size();\n"
889
+ "}\n");
890
+ WriteFieldDocComment(printer, descriptor_);
891
+ printer->Print(variables_,
892
+ "$deprecation$public $type$ get$capitalized_name$(int index) {\n"
893
+ " return $name$_.get(index);\n"
894
+ "}\n");
895
+ WriteFieldDocComment(printer, descriptor_);
896
+ printer->Print(variables_,
897
+ "$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder(\n"
898
+ " int index) {\n"
899
+ " return $name$_.get(index);\n"
900
+ "}\n");
901
+
902
+ }
903
+
904
+ void RepeatedImmutableMessageFieldGenerator::PrintNestedBuilderCondition(
905
+ io::Printer* printer,
906
+ const char* regular_case,
907
+ const char* nested_builder_case) const {
908
+ if (HasNestedBuilders(descriptor_->containing_type())) {
909
+ printer->Print(variables_, "if ($name$Builder_ == null) {\n");
910
+ printer->Indent();
911
+ printer->Print(variables_, regular_case);
912
+ printer->Outdent();
913
+ printer->Print("} else {\n");
914
+ printer->Indent();
915
+ printer->Print(variables_, nested_builder_case);
916
+ printer->Outdent();
917
+ printer->Print("}\n");
918
+ } else {
919
+ printer->Print(variables_, regular_case);
920
+ }
921
+ }
922
+
923
+ void RepeatedImmutableMessageFieldGenerator::PrintNestedBuilderFunction(
924
+ io::Printer* printer,
925
+ const char* method_prototype,
926
+ const char* regular_case,
927
+ const char* nested_builder_case,
928
+ const char* trailing_code) const {
929
+ printer->Print(variables_, method_prototype);
930
+ printer->Print(" {\n");
931
+ printer->Indent();
932
+ PrintNestedBuilderCondition(printer, regular_case, nested_builder_case);
933
+ if (trailing_code != NULL) {
934
+ printer->Print(variables_, trailing_code);
935
+ }
936
+ printer->Outdent();
937
+ printer->Print("}\n");
938
+ }
939
+
940
+ void RepeatedImmutableMessageFieldGenerator::
941
+ GenerateBuilderMembers(io::Printer* printer) const {
942
+ // When using nested-builders, the code initially works just like the
943
+ // non-nested builder case. It only creates a nested builder lazily on
944
+ // demand and then forever delegates to it after creation.
945
+
946
+ printer->Print(variables_,
947
+ // Used when the builder is null.
948
+ // One field is the list and the other field keeps track of whether the
949
+ // list is immutable. If it's immutable, the invariant is that it must
950
+ // either an instance of Collections.emptyList() or it's an ArrayList
951
+ // wrapped in a Collections.unmodifiableList() wrapper and nobody else has
952
+ // a refererence to the underlying ArrayList. This invariant allows us to
953
+ // share instances of lists between protocol buffers avoiding expensive
954
+ // memory allocations. Note, immutable is a strong guarantee here -- not
955
+ // just that the list cannot be modified via the reference but that the
956
+ // list can never be modified.
957
+ "private java.util.List<$type$> $name$_ =\n"
958
+ " java.util.Collections.emptyList();\n"
959
+
960
+ "private void ensure$capitalized_name$IsMutable() {\n"
961
+ " if (!$get_mutable_bit_builder$) {\n"
962
+ " $name$_ = new java.util.ArrayList<$type$>($name$_);\n"
963
+ " $set_mutable_bit_builder$;\n"
964
+ " }\n"
965
+ "}\n"
966
+ "\n");
967
+
968
+ if (HasNestedBuilders(descriptor_->containing_type())) {
969
+ printer->Print(variables_,
970
+ // If this builder is non-null, it is used and the other fields are
971
+ // ignored.
972
+ "private com.google.protobuf.RepeatedFieldBuilder<\n"
973
+ " $type$, $type$.Builder, $type$OrBuilder> $name$Builder_;\n"
974
+ "\n");
975
+ }
976
+
977
+ // The comments above the methods below are based on a hypothetical
978
+ // repeated field of type "Field" called "RepeatedField".
979
+
980
+ // List<Field> getRepeatedFieldList()
981
+ WriteFieldDocComment(printer, descriptor_);
982
+ PrintNestedBuilderFunction(printer,
983
+ "$deprecation$public java.util.List<$type$> get$capitalized_name$List()",
984
+
985
+ "return java.util.Collections.unmodifiableList($name$_);\n",
986
+ "return $name$Builder_.getMessageList();\n",
987
+
988
+ NULL);
989
+
990
+ // int getRepeatedFieldCount()
991
+ WriteFieldDocComment(printer, descriptor_);
992
+ PrintNestedBuilderFunction(printer,
993
+ "$deprecation$public int get$capitalized_name$Count()",
994
+
995
+ "return $name$_.size();\n",
996
+ "return $name$Builder_.getCount();\n",
997
+
998
+ NULL);
999
+
1000
+ // Field getRepeatedField(int index)
1001
+ WriteFieldDocComment(printer, descriptor_);
1002
+ PrintNestedBuilderFunction(printer,
1003
+ "$deprecation$public $type$ get$capitalized_name$(int index)",
1004
+
1005
+ "return $name$_.get(index);\n",
1006
+
1007
+ "return $name$Builder_.getMessage(index);\n",
1008
+
1009
+ NULL);
1010
+
1011
+ // Builder setRepeatedField(int index, Field value)
1012
+ WriteFieldDocComment(printer, descriptor_);
1013
+ PrintNestedBuilderFunction(printer,
1014
+ "$deprecation$public Builder set$capitalized_name$(\n"
1015
+ " int index, $type$ value)",
1016
+ "if (value == null) {\n"
1017
+ " throw new NullPointerException();\n"
1018
+ "}\n"
1019
+ "ensure$capitalized_name$IsMutable();\n"
1020
+ "$name$_.set(index, value);\n"
1021
+ "$on_changed$\n",
1022
+ "$name$Builder_.setMessage(index, value);\n",
1023
+ "return this;\n");
1024
+
1025
+ // Builder setRepeatedField(int index, Field.Builder builderForValue)
1026
+ WriteFieldDocComment(printer, descriptor_);
1027
+ PrintNestedBuilderFunction(printer,
1028
+ "$deprecation$public Builder set$capitalized_name$(\n"
1029
+ " int index, $type$.Builder builderForValue)",
1030
+
1031
+ "ensure$capitalized_name$IsMutable();\n"
1032
+ "$name$_.set(index, builderForValue.build());\n"
1033
+ "$on_changed$\n",
1034
+
1035
+ "$name$Builder_.setMessage(index, builderForValue.build());\n",
1036
+
1037
+ "return this;\n");
1038
+
1039
+ // Builder addRepeatedField(Field value)
1040
+ WriteFieldDocComment(printer, descriptor_);
1041
+ PrintNestedBuilderFunction(printer,
1042
+ "$deprecation$public Builder add$capitalized_name$($type$ value)",
1043
+
1044
+ "if (value == null) {\n"
1045
+ " throw new NullPointerException();\n"
1046
+ "}\n"
1047
+ "ensure$capitalized_name$IsMutable();\n"
1048
+ "$name$_.add(value);\n"
1049
+
1050
+ "$on_changed$\n",
1051
+
1052
+ "$name$Builder_.addMessage(value);\n",
1053
+
1054
+ "return this;\n");
1055
+
1056
+ // Builder addRepeatedField(int index, Field value)
1057
+ WriteFieldDocComment(printer, descriptor_);
1058
+ PrintNestedBuilderFunction(printer,
1059
+ "$deprecation$public Builder add$capitalized_name$(\n"
1060
+ " int index, $type$ value)",
1061
+
1062
+ "if (value == null) {\n"
1063
+ " throw new NullPointerException();\n"
1064
+ "}\n"
1065
+ "ensure$capitalized_name$IsMutable();\n"
1066
+ "$name$_.add(index, value);\n"
1067
+ "$on_changed$\n",
1068
+
1069
+ "$name$Builder_.addMessage(index, value);\n",
1070
+
1071
+ "return this;\n");
1072
+
1073
+ // Builder addRepeatedField(Field.Builder builderForValue)
1074
+ WriteFieldDocComment(printer, descriptor_);
1075
+ PrintNestedBuilderFunction(printer,
1076
+ "$deprecation$public Builder add$capitalized_name$(\n"
1077
+ " $type$.Builder builderForValue)",
1078
+
1079
+ "ensure$capitalized_name$IsMutable();\n"
1080
+ "$name$_.add(builderForValue.build());\n"
1081
+ "$on_changed$\n",
1082
+
1083
+ "$name$Builder_.addMessage(builderForValue.build());\n",
1084
+
1085
+ "return this;\n");
1086
+
1087
+ // Builder addRepeatedField(int index, Field.Builder builderForValue)
1088
+ WriteFieldDocComment(printer, descriptor_);
1089
+ PrintNestedBuilderFunction(printer,
1090
+ "$deprecation$public Builder add$capitalized_name$(\n"
1091
+ " int index, $type$.Builder builderForValue)",
1092
+
1093
+ "ensure$capitalized_name$IsMutable();\n"
1094
+ "$name$_.add(index, builderForValue.build());\n"
1095
+ "$on_changed$\n",
1096
+
1097
+ "$name$Builder_.addMessage(index, builderForValue.build());\n",
1098
+
1099
+ "return this;\n");
1100
+
1101
+ // Builder addAllRepeatedField(Iterable<Field> values)
1102
+ WriteFieldDocComment(printer, descriptor_);
1103
+ PrintNestedBuilderFunction(printer,
1104
+ "$deprecation$public Builder addAll$capitalized_name$(\n"
1105
+ " java.lang.Iterable<? extends $type$> values)",
1106
+
1107
+ "ensure$capitalized_name$IsMutable();\n"
1108
+ "com.google.protobuf.AbstractMessageLite.Builder.addAll(\n"
1109
+ " values, $name$_);\n"
1110
+ "$on_changed$\n",
1111
+
1112
+ "$name$Builder_.addAllMessages(values);\n",
1113
+
1114
+ "return this;\n");
1115
+
1116
+ // Builder clearAllRepeatedField()
1117
+ WriteFieldDocComment(printer, descriptor_);
1118
+ PrintNestedBuilderFunction(printer,
1119
+ "$deprecation$public Builder clear$capitalized_name$()",
1120
+
1121
+ "$name$_ = java.util.Collections.emptyList();\n"
1122
+ "$clear_mutable_bit_builder$;\n"
1123
+ "$on_changed$\n",
1124
+
1125
+ "$name$Builder_.clear();\n",
1126
+
1127
+ "return this;\n");
1128
+
1129
+ // Builder removeRepeatedField(int index)
1130
+ WriteFieldDocComment(printer, descriptor_);
1131
+ PrintNestedBuilderFunction(printer,
1132
+ "$deprecation$public Builder remove$capitalized_name$(int index)",
1133
+
1134
+ "ensure$capitalized_name$IsMutable();\n"
1135
+ "$name$_.remove(index);\n"
1136
+ "$on_changed$\n",
1137
+
1138
+ "$name$Builder_.remove(index);\n",
1139
+
1140
+ "return this;\n");
1141
+
1142
+ if (HasNestedBuilders(descriptor_->containing_type())) {
1143
+ WriteFieldDocComment(printer, descriptor_);
1144
+ printer->Print(variables_,
1145
+ "$deprecation$public $type$.Builder get$capitalized_name$Builder(\n"
1146
+ " int index) {\n"
1147
+ " return get$capitalized_name$FieldBuilder().getBuilder(index);\n"
1148
+ "}\n");
1149
+
1150
+ WriteFieldDocComment(printer, descriptor_);
1151
+ printer->Print(variables_,
1152
+ "$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder(\n"
1153
+ " int index) {\n"
1154
+ " if ($name$Builder_ == null) {\n"
1155
+ " return $name$_.get(index);"
1156
+ " } else {\n"
1157
+ " return $name$Builder_.getMessageOrBuilder(index);\n"
1158
+ " }\n"
1159
+ "}\n");
1160
+
1161
+ WriteFieldDocComment(printer, descriptor_);
1162
+ printer->Print(variables_,
1163
+ "$deprecation$public java.util.List<? extends $type$OrBuilder> \n"
1164
+ " get$capitalized_name$OrBuilderList() {\n"
1165
+ " if ($name$Builder_ != null) {\n"
1166
+ " return $name$Builder_.getMessageOrBuilderList();\n"
1167
+ " } else {\n"
1168
+ " return java.util.Collections.unmodifiableList($name$_);\n"
1169
+ " }\n"
1170
+ "}\n");
1171
+
1172
+ WriteFieldDocComment(printer, descriptor_);
1173
+ printer->Print(variables_,
1174
+ "$deprecation$public $type$.Builder add$capitalized_name$Builder() {\n"
1175
+ " return get$capitalized_name$FieldBuilder().addBuilder(\n"
1176
+ " $type$.getDefaultInstance());\n"
1177
+ "}\n");
1178
+ WriteFieldDocComment(printer, descriptor_);
1179
+ printer->Print(variables_,
1180
+ "$deprecation$public $type$.Builder add$capitalized_name$Builder(\n"
1181
+ " int index) {\n"
1182
+ " return get$capitalized_name$FieldBuilder().addBuilder(\n"
1183
+ " index, $type$.getDefaultInstance());\n"
1184
+ "}\n");
1185
+ WriteFieldDocComment(printer, descriptor_);
1186
+ printer->Print(variables_,
1187
+ "$deprecation$public java.util.List<$type$.Builder> \n"
1188
+ " get$capitalized_name$BuilderList() {\n"
1189
+ " return get$capitalized_name$FieldBuilder().getBuilderList();\n"
1190
+ "}\n"
1191
+ "private com.google.protobuf.RepeatedFieldBuilder<\n"
1192
+ " $type$, $type$.Builder, $type$OrBuilder> \n"
1193
+ " get$capitalized_name$FieldBuilder() {\n"
1194
+ " if ($name$Builder_ == null) {\n"
1195
+ " $name$Builder_ = new com.google.protobuf.RepeatedFieldBuilder<\n"
1196
+ " $type$, $type$.Builder, $type$OrBuilder>(\n"
1197
+ " $name$_,\n"
1198
+ " $get_mutable_bit_builder$,\n"
1199
+ " getParentForChildren(),\n"
1200
+ " isClean());\n"
1201
+ " $name$_ = null;\n"
1202
+ " }\n"
1203
+ " return $name$Builder_;\n"
1204
+ "}\n");
1205
+ }
1206
+ }
1207
+
1208
+ void RepeatedImmutableMessageFieldGenerator::
1209
+ GenerateFieldBuilderInitializationCode(io::Printer* printer) const {
1210
+ printer->Print(variables_,
1211
+ "get$capitalized_name$FieldBuilder();\n");
1212
+ }
1213
+
1214
+ void RepeatedImmutableMessageFieldGenerator::
1215
+ GenerateInitializationCode(io::Printer* printer) const {
1216
+ printer->Print(variables_, "$name$_ = java.util.Collections.emptyList();\n");
1217
+ }
1218
+
1219
+ void RepeatedImmutableMessageFieldGenerator::
1220
+ GenerateBuilderClearCode(io::Printer* printer) const {
1221
+ PrintNestedBuilderCondition(printer,
1222
+ "$name$_ = java.util.Collections.emptyList();\n"
1223
+ "$clear_mutable_bit_builder$;\n",
1224
+
1225
+ "$name$Builder_.clear();\n");
1226
+ }
1227
+
1228
+ void RepeatedImmutableMessageFieldGenerator::
1229
+ GenerateMergingCode(io::Printer* printer) const {
1230
+ // The code below does two optimizations (non-nested builder case):
1231
+ // 1. If the other list is empty, there's nothing to do. This ensures we
1232
+ // don't allocate a new array if we already have an immutable one.
1233
+ // 2. If the other list is non-empty and our current list is empty, we can
1234
+ // reuse the other list which is guaranteed to be immutable.
1235
+ PrintNestedBuilderCondition(printer,
1236
+ "if (!other.$name$_.isEmpty()) {\n"
1237
+ " if ($name$_.isEmpty()) {\n"
1238
+ " $name$_ = other.$name$_;\n"
1239
+ " $clear_mutable_bit_builder$;\n"
1240
+ " } else {\n"
1241
+ " ensure$capitalized_name$IsMutable();\n"
1242
+ " $name$_.addAll(other.$name$_);\n"
1243
+ " }\n"
1244
+ " $on_changed$\n"
1245
+ "}\n",
1246
+
1247
+ "if (!other.$name$_.isEmpty()) {\n"
1248
+ " if ($name$Builder_.isEmpty()) {\n"
1249
+ " $name$Builder_.dispose();\n"
1250
+ " $name$Builder_ = null;\n"
1251
+ " $name$_ = other.$name$_;\n"
1252
+ " $clear_mutable_bit_builder$;\n"
1253
+ " $name$Builder_ = \n"
1254
+ " com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?\n"
1255
+ " get$capitalized_name$FieldBuilder() : null;\n"
1256
+ " } else {\n"
1257
+ " $name$Builder_.addAllMessages(other.$name$_);\n"
1258
+ " }\n"
1259
+ "}\n");
1260
+ }
1261
+
1262
+ void RepeatedImmutableMessageFieldGenerator::
1263
+ GenerateBuildingCode(io::Printer* printer) const {
1264
+ // The code below (non-nested builder case) ensures that the result has an
1265
+ // immutable list. If our list is immutable, we can just reuse it. If not,
1266
+ // we make it immutable.
1267
+ PrintNestedBuilderCondition(printer,
1268
+ "if ($get_mutable_bit_builder$) {\n"
1269
+ " $name$_ = java.util.Collections.unmodifiableList($name$_);\n"
1270
+ " $clear_mutable_bit_builder$;\n"
1271
+ "}\n"
1272
+ "result.$name$_ = $name$_;\n",
1273
+
1274
+ "result.$name$_ = $name$Builder_.build();\n");
1275
+ }
1276
+
1277
+ void RepeatedImmutableMessageFieldGenerator::
1278
+ GenerateParsingCode(io::Printer* printer) const {
1279
+ printer->Print(variables_,
1280
+ "if (!$get_mutable_bit_parser$) {\n"
1281
+ " $name$_ = new java.util.ArrayList<$type$>();\n"
1282
+ " $set_mutable_bit_parser$;\n"
1283
+ "}\n");
1284
+
1285
+ if (GetType(descriptor_) == FieldDescriptor::TYPE_GROUP) {
1286
+ printer->Print(variables_,
1287
+ "$name$_.add(input.readGroup($number$, $type$.PARSER,\n"
1288
+ " extensionRegistry));\n");
1289
+ } else {
1290
+ printer->Print(variables_,
1291
+ "$name$_.add(input.readMessage($type$.PARSER, extensionRegistry));\n");
1292
+ }
1293
+ }
1294
+
1295
+ void RepeatedImmutableMessageFieldGenerator::
1296
+ GenerateParsingDoneCode(io::Printer* printer) const {
1297
+ printer->Print(variables_,
1298
+ "if ($get_mutable_bit_parser$) {\n"
1299
+ " $name$_ = java.util.Collections.unmodifiableList($name$_);\n"
1300
+ "}\n");
1301
+ }
1302
+
1303
+ void RepeatedImmutableMessageFieldGenerator::
1304
+ GenerateSerializationCode(io::Printer* printer) const {
1305
+ printer->Print(variables_,
1306
+ "for (int i = 0; i < $name$_.size(); i++) {\n"
1307
+ " output.write$group_or_message$($number$, $name$_.get(i));\n"
1308
+ "}\n");
1309
+ }
1310
+
1311
+ void RepeatedImmutableMessageFieldGenerator::
1312
+ GenerateSerializedSizeCode(io::Printer* printer) const {
1313
+ printer->Print(variables_,
1314
+ "for (int i = 0; i < $name$_.size(); i++) {\n"
1315
+ " size += com.google.protobuf.CodedOutputStream\n"
1316
+ " .compute$group_or_message$Size($number$, $name$_.get(i));\n"
1317
+ "}\n");
1318
+ }
1319
+
1320
+ void RepeatedImmutableMessageFieldGenerator::
1321
+ GenerateEqualsCode(io::Printer* printer) const {
1322
+ printer->Print(variables_,
1323
+ "result = result && get$capitalized_name$List()\n"
1324
+ " .equals(other.get$capitalized_name$List());\n");
1325
+ }
1326
+
1327
+ void RepeatedImmutableMessageFieldGenerator::
1328
+ GenerateHashCode(io::Printer* printer) const {
1329
+ printer->Print(variables_,
1330
+ "if (get$capitalized_name$Count() > 0) {\n"
1331
+ " hash = (37 * hash) + $constant_name$;\n"
1332
+ " hash = (53 * hash) + get$capitalized_name$List().hashCode();\n"
1333
+ "}\n");
1334
+ }
1335
+
1336
+ string RepeatedImmutableMessageFieldGenerator::GetBoxedType() const {
1337
+ return name_resolver_->GetImmutableClassName(descriptor_->message_type());
1338
+ }
1339
+
1340
+ } // namespace java
1341
+ } // namespace compiler
1342
+ } // namespace protobuf
1343
+ } // namespace google