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,87 @@
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 <algorithm>
36
+
37
+ #include <google/protobuf/repeated_field.h>
38
+ #include <google/protobuf/stubs/common.h>
39
+
40
+ namespace google {
41
+ namespace protobuf {
42
+
43
+ namespace internal {
44
+
45
+ void RepeatedPtrFieldBase::Reserve(int new_size) {
46
+ if (total_size_ >= new_size) return;
47
+
48
+ void** old_elements = elements_;
49
+ total_size_ = max(kMinRepeatedFieldAllocationSize,
50
+ max(total_size_ * 2, new_size));
51
+ elements_ = new void*[total_size_];
52
+ if (old_elements != NULL) {
53
+ memcpy(elements_, old_elements, allocated_size_ * sizeof(elements_[0]));
54
+ delete [] old_elements;
55
+ }
56
+ }
57
+
58
+ void RepeatedPtrFieldBase::Swap(RepeatedPtrFieldBase* other) {
59
+ if (this == other) return;
60
+ void** swap_elements = elements_;
61
+ int swap_current_size = current_size_;
62
+ int swap_allocated_size = allocated_size_;
63
+ int swap_total_size = total_size_;
64
+
65
+ elements_ = other->elements_;
66
+ current_size_ = other->current_size_;
67
+ allocated_size_ = other->allocated_size_;
68
+ total_size_ = other->total_size_;
69
+
70
+ other->elements_ = swap_elements;
71
+ other->current_size_ = swap_current_size;
72
+ other->allocated_size_ = swap_allocated_size;
73
+ other->total_size_ = swap_total_size;
74
+ }
75
+
76
+ string* StringTypeHandlerBase::New() {
77
+ return new string;
78
+ }
79
+ void StringTypeHandlerBase::Delete(string* value) {
80
+ delete value;
81
+ }
82
+
83
+ } // namespace internal
84
+
85
+
86
+ } // namespace protobuf
87
+ } // namespace google
@@ -0,0 +1,1603 @@
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
+ // RepeatedField and RepeatedPtrField are used by generated protocol message
36
+ // classes to manipulate repeated fields. These classes are very similar to
37
+ // STL's vector, but include a number of optimizations found to be useful
38
+ // specifically in the case of Protocol Buffers. RepeatedPtrField is
39
+ // particularly different from STL vector as it manages ownership of the
40
+ // pointers that it contains.
41
+ //
42
+ // Typically, clients should not need to access RepeatedField objects directly,
43
+ // but should instead use the accessor functions generated automatically by the
44
+ // protocol compiler.
45
+
46
+ #ifndef GOOGLE_PROTOBUF_REPEATED_FIELD_H__
47
+ #define GOOGLE_PROTOBUF_REPEATED_FIELD_H__
48
+
49
+ #ifdef _MSC_VER
50
+ // This is required for min/max on VS2013 only.
51
+ #include <algorithm>
52
+ #endif
53
+
54
+ #include <string>
55
+ #include <iterator>
56
+ #include <google/protobuf/stubs/common.h>
57
+ #include <google/protobuf/stubs/type_traits.h>
58
+ #include <google/protobuf/generated_message_util.h>
59
+ #include <google/protobuf/message_lite.h>
60
+
61
+ namespace google {
62
+
63
+ namespace upb {
64
+ namespace google_opensource {
65
+ class GMR_Handlers;
66
+ } // namespace google_opensource
67
+ } // namespace upb
68
+
69
+ namespace protobuf {
70
+
71
+ class Message;
72
+
73
+ namespace internal {
74
+
75
+ static const int kMinRepeatedFieldAllocationSize = 4;
76
+
77
+ // A utility function for logging that doesn't need any template types.
78
+ void LogIndexOutOfBounds(int index, int size);
79
+
80
+ template <typename Iter>
81
+ inline int CalculateReserve(Iter begin, Iter end, std::forward_iterator_tag) {
82
+ return std::distance(begin, end);
83
+ }
84
+
85
+ template <typename Iter>
86
+ inline int CalculateReserve(Iter begin, Iter end, std::input_iterator_tag) {
87
+ return -1;
88
+ }
89
+
90
+ template <typename Iter>
91
+ inline int CalculateReserve(Iter begin, Iter end) {
92
+ typedef typename std::iterator_traits<Iter>::iterator_category Category;
93
+ return CalculateReserve(begin, end, Category());
94
+ }
95
+ } // namespace internal
96
+
97
+
98
+ // RepeatedField is used to represent repeated fields of a primitive type (in
99
+ // other words, everything except strings and nested Messages). Most users will
100
+ // not ever use a RepeatedField directly; they will use the get-by-index,
101
+ // set-by-index, and add accessors that are generated for all repeated fields.
102
+ template <typename Element>
103
+ class RepeatedField {
104
+ public:
105
+ RepeatedField();
106
+ RepeatedField(const RepeatedField& other);
107
+ template <typename Iter>
108
+ RepeatedField(Iter begin, const Iter& end);
109
+ ~RepeatedField();
110
+
111
+ RepeatedField& operator=(const RepeatedField& other);
112
+
113
+ bool empty() const;
114
+ int size() const;
115
+
116
+ const Element& Get(int index) const;
117
+ Element* Mutable(int index);
118
+ void Set(int index, const Element& value);
119
+ void Add(const Element& value);
120
+ Element* Add();
121
+ // Remove the last element in the array.
122
+ void RemoveLast();
123
+
124
+ // Extract elements with indices in "[start .. start+num-1]".
125
+ // Copy them into "elements[0 .. num-1]" if "elements" is not NULL.
126
+ // Caution: implementation also moves elements with indices [start+num ..].
127
+ // Calling this routine inside a loop can cause quadratic behavior.
128
+ void ExtractSubrange(int start, int num, Element* elements);
129
+
130
+ void Clear();
131
+ void MergeFrom(const RepeatedField& other);
132
+ void CopyFrom(const RepeatedField& other);
133
+
134
+ // Reserve space to expand the field to at least the given size. If the
135
+ // array is grown, it will always be at least doubled in size.
136
+ void Reserve(int new_size);
137
+
138
+ // Resize the RepeatedField to a new, smaller size. This is O(1).
139
+ void Truncate(int new_size);
140
+
141
+ void AddAlreadyReserved(const Element& value);
142
+ Element* AddAlreadyReserved();
143
+ int Capacity() const;
144
+
145
+ // Like STL resize. Uses value to fill appended elements.
146
+ // Like Truncate() if new_size <= size(), otherwise this is
147
+ // O(new_size - size()).
148
+ void Resize(int new_size, const Element& value);
149
+
150
+ // Gets the underlying array. This pointer is possibly invalidated by
151
+ // any add or remove operation.
152
+ Element* mutable_data();
153
+ const Element* data() const;
154
+
155
+ // Swap entire contents with "other".
156
+ void Swap(RepeatedField* other);
157
+
158
+ // Swap two elements.
159
+ void SwapElements(int index1, int index2);
160
+
161
+ // STL-like iterator support
162
+ typedef Element* iterator;
163
+ typedef const Element* const_iterator;
164
+ typedef Element value_type;
165
+ typedef value_type& reference;
166
+ typedef const value_type& const_reference;
167
+ typedef value_type* pointer;
168
+ typedef const value_type* const_pointer;
169
+ typedef int size_type;
170
+ typedef ptrdiff_t difference_type;
171
+
172
+ iterator begin();
173
+ const_iterator begin() const;
174
+ iterator end();
175
+ const_iterator end() const;
176
+
177
+ // Reverse iterator support
178
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
179
+ typedef std::reverse_iterator<iterator> reverse_iterator;
180
+ reverse_iterator rbegin() {
181
+ return reverse_iterator(end());
182
+ }
183
+ const_reverse_iterator rbegin() const {
184
+ return const_reverse_iterator(end());
185
+ }
186
+ reverse_iterator rend() {
187
+ return reverse_iterator(begin());
188
+ }
189
+ const_reverse_iterator rend() const {
190
+ return const_reverse_iterator(begin());
191
+ }
192
+
193
+ // Returns the number of bytes used by the repeated field, excluding
194
+ // sizeof(*this)
195
+ int SpaceUsedExcludingSelf() const;
196
+
197
+ private:
198
+ static const int kInitialSize = 0;
199
+
200
+ Element* elements_;
201
+ int current_size_;
202
+ int total_size_;
203
+
204
+ // Move the contents of |from| into |to|, possibly clobbering |from| in the
205
+ // process. For primitive types this is just a memcpy(), but it could be
206
+ // specialized for non-primitive types to, say, swap each element instead.
207
+ void MoveArray(Element to[], Element from[], int size);
208
+
209
+ // Copy the elements of |from| into |to|.
210
+ void CopyArray(Element to[], const Element from[], int size);
211
+ };
212
+
213
+ namespace internal {
214
+ template <typename It> class RepeatedPtrIterator;
215
+ template <typename It, typename VoidPtr> class RepeatedPtrOverPtrsIterator;
216
+ } // namespace internal
217
+
218
+ namespace internal {
219
+
220
+ // This is a helper template to copy an array of elements effeciently when they
221
+ // have a trivial copy constructor, and correctly otherwise. This really
222
+ // shouldn't be necessary, but our compiler doesn't optimize std::copy very
223
+ // effectively.
224
+ template <typename Element,
225
+ bool HasTrivialCopy = has_trivial_copy<Element>::value>
226
+ struct ElementCopier {
227
+ void operator()(Element to[], const Element from[], int array_size);
228
+ };
229
+
230
+ } // namespace internal
231
+
232
+ namespace internal {
233
+
234
+ // This is the common base class for RepeatedPtrFields. It deals only in void*
235
+ // pointers. Users should not use this interface directly.
236
+ //
237
+ // The methods of this interface correspond to the methods of RepeatedPtrField,
238
+ // but may have a template argument called TypeHandler. Its signature is:
239
+ // class TypeHandler {
240
+ // public:
241
+ // typedef MyType Type;
242
+ // static Type* New();
243
+ // static void Delete(Type*);
244
+ // static void Clear(Type*);
245
+ // static void Merge(const Type& from, Type* to);
246
+ //
247
+ // // Only needs to be implemented if SpaceUsedExcludingSelf() is called.
248
+ // static int SpaceUsed(const Type&);
249
+ // };
250
+ class LIBPROTOBUF_EXPORT RepeatedPtrFieldBase {
251
+ protected:
252
+ // The reflection implementation needs to call protected methods directly,
253
+ // reinterpreting pointers as being to Message instead of a specific Message
254
+ // subclass.
255
+ friend class GeneratedMessageReflection;
256
+
257
+ // ExtensionSet stores repeated message extensions as
258
+ // RepeatedPtrField<MessageLite>, but non-lite ExtensionSets need to
259
+ // implement SpaceUsed(), and thus need to call SpaceUsedExcludingSelf()
260
+ // reinterpreting MessageLite as Message. ExtensionSet also needs to make
261
+ // use of AddFromCleared(), which is not part of the public interface.
262
+ friend class ExtensionSet;
263
+
264
+ // To parse directly into a proto2 generated class, the upb class GMR_Handlers
265
+ // needs to be able to modify a RepeatedPtrFieldBase directly.
266
+ friend class LIBPROTOBUF_EXPORT upb::google_opensource::GMR_Handlers;
267
+
268
+ RepeatedPtrFieldBase();
269
+
270
+ // Must be called from destructor.
271
+ template <typename TypeHandler>
272
+ void Destroy();
273
+
274
+ bool empty() const;
275
+ int size() const;
276
+
277
+ template <typename TypeHandler>
278
+ const typename TypeHandler::Type& Get(int index) const;
279
+ template <typename TypeHandler>
280
+ typename TypeHandler::Type* Mutable(int index);
281
+ template <typename TypeHandler>
282
+ typename TypeHandler::Type* Add();
283
+ template <typename TypeHandler>
284
+ void RemoveLast();
285
+ template <typename TypeHandler>
286
+ void Clear();
287
+ template <typename TypeHandler>
288
+ void MergeFrom(const RepeatedPtrFieldBase& other);
289
+ template <typename TypeHandler>
290
+ void CopyFrom(const RepeatedPtrFieldBase& other);
291
+
292
+ void CloseGap(int start, int num) {
293
+ // Close up a gap of "num" elements starting at offset "start".
294
+ for (int i = start + num; i < allocated_size_; ++i)
295
+ elements_[i - num] = elements_[i];
296
+ current_size_ -= num;
297
+ allocated_size_ -= num;
298
+ }
299
+
300
+ void Reserve(int new_size);
301
+
302
+ int Capacity() const;
303
+
304
+ // Used for constructing iterators.
305
+ void* const* raw_data() const;
306
+ void** raw_mutable_data() const;
307
+
308
+ template <typename TypeHandler>
309
+ typename TypeHandler::Type** mutable_data();
310
+ template <typename TypeHandler>
311
+ const typename TypeHandler::Type* const* data() const;
312
+
313
+ void Swap(RepeatedPtrFieldBase* other);
314
+
315
+ void SwapElements(int index1, int index2);
316
+
317
+ template <typename TypeHandler>
318
+ int SpaceUsedExcludingSelf() const;
319
+
320
+
321
+ // Advanced memory management --------------------------------------
322
+
323
+ // Like Add(), but if there are no cleared objects to use, returns NULL.
324
+ template <typename TypeHandler>
325
+ typename TypeHandler::Type* AddFromCleared();
326
+
327
+ template <typename TypeHandler>
328
+ void AddAllocated(typename TypeHandler::Type* value);
329
+ template <typename TypeHandler>
330
+ typename TypeHandler::Type* ReleaseLast();
331
+
332
+ int ClearedCount() const;
333
+ template <typename TypeHandler>
334
+ void AddCleared(typename TypeHandler::Type* value);
335
+ template <typename TypeHandler>
336
+ typename TypeHandler::Type* ReleaseCleared();
337
+
338
+ private:
339
+ static const int kInitialSize = 0;
340
+
341
+ void** elements_;
342
+ int current_size_;
343
+ int allocated_size_;
344
+ int total_size_;
345
+
346
+ template <typename TypeHandler>
347
+ static inline typename TypeHandler::Type* cast(void* element) {
348
+ return reinterpret_cast<typename TypeHandler::Type*>(element);
349
+ }
350
+ template <typename TypeHandler>
351
+ static inline const typename TypeHandler::Type* cast(const void* element) {
352
+ return reinterpret_cast<const typename TypeHandler::Type*>(element);
353
+ }
354
+
355
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPtrFieldBase);
356
+ };
357
+
358
+ template <typename GenericType>
359
+ class GenericTypeHandler {
360
+ public:
361
+ typedef GenericType Type;
362
+ static GenericType* New() { return new GenericType; }
363
+ static void Delete(GenericType* value) { delete value; }
364
+ static void Clear(GenericType* value) { value->Clear(); }
365
+ static void Merge(const GenericType& from, GenericType* to) {
366
+ to->MergeFrom(from);
367
+ }
368
+ static int SpaceUsed(const GenericType& value) { return value.SpaceUsed(); }
369
+ static const Type& default_instance() { return Type::default_instance(); }
370
+ };
371
+
372
+ template <>
373
+ inline void GenericTypeHandler<MessageLite>::Merge(
374
+ const MessageLite& from, MessageLite* to) {
375
+ to->CheckTypeAndMergeFrom(from);
376
+ }
377
+
378
+ template <>
379
+ inline const MessageLite& GenericTypeHandler<MessageLite>::default_instance() {
380
+ // Yes, the behavior of the code is undefined, but this function is only
381
+ // called when we're already deep into the world of undefined, because the
382
+ // caller called Get(index) out of bounds.
383
+ MessageLite* null = NULL;
384
+ return *null;
385
+ }
386
+
387
+ template <>
388
+ inline const Message& GenericTypeHandler<Message>::default_instance() {
389
+ // Yes, the behavior of the code is undefined, but this function is only
390
+ // called when we're already deep into the world of undefined, because the
391
+ // caller called Get(index) out of bounds.
392
+ Message* null = NULL;
393
+ return *null;
394
+ }
395
+
396
+
397
+ // HACK: If a class is declared as DLL-exported in MSVC, it insists on
398
+ // generating copies of all its methods -- even inline ones -- to include
399
+ // in the DLL. But SpaceUsed() calls StringSpaceUsedExcludingSelf() which
400
+ // isn't in the lite library, therefore the lite library cannot link if
401
+ // StringTypeHandler is exported. So, we factor out StringTypeHandlerBase,
402
+ // export that, then make StringTypeHandler be a subclass which is NOT
403
+ // exported.
404
+ // TODO(kenton): There has to be a better way.
405
+ class LIBPROTOBUF_EXPORT StringTypeHandlerBase {
406
+ public:
407
+ typedef string Type;
408
+ static string* New();
409
+ static void Delete(string* value);
410
+ static void Clear(string* value) { value->clear(); }
411
+ static void Merge(const string& from, string* to) { *to = from; }
412
+ static const Type& default_instance() {
413
+ return ::google::protobuf::internal::GetEmptyString();
414
+ }
415
+ };
416
+
417
+ class StringTypeHandler : public StringTypeHandlerBase {
418
+ public:
419
+ static int SpaceUsed(const string& value) {
420
+ return sizeof(value) + StringSpaceUsedExcludingSelf(value);
421
+ }
422
+ };
423
+
424
+
425
+ } // namespace internal
426
+
427
+ // RepeatedPtrField is like RepeatedField, but used for repeated strings or
428
+ // Messages.
429
+ template <typename Element>
430
+ class RepeatedPtrField : public internal::RepeatedPtrFieldBase {
431
+ public:
432
+ RepeatedPtrField();
433
+ RepeatedPtrField(const RepeatedPtrField& other);
434
+ template <typename Iter>
435
+ RepeatedPtrField(Iter begin, const Iter& end);
436
+ ~RepeatedPtrField();
437
+
438
+ RepeatedPtrField& operator=(const RepeatedPtrField& other);
439
+
440
+ bool empty() const;
441
+ int size() const;
442
+
443
+ const Element& Get(int index) const;
444
+ Element* Mutable(int index);
445
+ Element* Add();
446
+
447
+ // Remove the last element in the array.
448
+ // Ownership of the element is retained by the array.
449
+ void RemoveLast();
450
+
451
+ // Delete elements with indices in the range [start .. start+num-1].
452
+ // Caution: implementation moves all elements with indices [start+num .. ].
453
+ // Calling this routine inside a loop can cause quadratic behavior.
454
+ void DeleteSubrange(int start, int num);
455
+
456
+ void Clear();
457
+ void MergeFrom(const RepeatedPtrField& other);
458
+ void CopyFrom(const RepeatedPtrField& other);
459
+
460
+ // Reserve space to expand the field to at least the given size. This only
461
+ // resizes the pointer array; it doesn't allocate any objects. If the
462
+ // array is grown, it will always be at least doubled in size.
463
+ void Reserve(int new_size);
464
+
465
+ int Capacity() const;
466
+
467
+ // Gets the underlying array. This pointer is possibly invalidated by
468
+ // any add or remove operation.
469
+ Element** mutable_data();
470
+ const Element* const* data() const;
471
+
472
+ // Swap entire contents with "other".
473
+ void Swap(RepeatedPtrField* other);
474
+
475
+ // Swap two elements.
476
+ void SwapElements(int index1, int index2);
477
+
478
+ // STL-like iterator support
479
+ typedef internal::RepeatedPtrIterator<Element> iterator;
480
+ typedef internal::RepeatedPtrIterator<const Element> const_iterator;
481
+ typedef Element value_type;
482
+ typedef value_type& reference;
483
+ typedef const value_type& const_reference;
484
+ typedef value_type* pointer;
485
+ typedef const value_type* const_pointer;
486
+ typedef int size_type;
487
+ typedef ptrdiff_t difference_type;
488
+
489
+ iterator begin();
490
+ const_iterator begin() const;
491
+ iterator end();
492
+ const_iterator end() const;
493
+
494
+ // Reverse iterator support
495
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
496
+ typedef std::reverse_iterator<iterator> reverse_iterator;
497
+ reverse_iterator rbegin() {
498
+ return reverse_iterator(end());
499
+ }
500
+ const_reverse_iterator rbegin() const {
501
+ return const_reverse_iterator(end());
502
+ }
503
+ reverse_iterator rend() {
504
+ return reverse_iterator(begin());
505
+ }
506
+ const_reverse_iterator rend() const {
507
+ return const_reverse_iterator(begin());
508
+ }
509
+
510
+ // Custom STL-like iterator that iterates over and returns the underlying
511
+ // pointers to Element rather than Element itself.
512
+ typedef internal::RepeatedPtrOverPtrsIterator<Element, void*>
513
+ pointer_iterator;
514
+ typedef internal::RepeatedPtrOverPtrsIterator<const Element, const void*>
515
+ const_pointer_iterator;
516
+ pointer_iterator pointer_begin();
517
+ const_pointer_iterator pointer_begin() const;
518
+ pointer_iterator pointer_end();
519
+ const_pointer_iterator pointer_end() const;
520
+
521
+ // Returns (an estimate of) the number of bytes used by the repeated field,
522
+ // excluding sizeof(*this).
523
+ int SpaceUsedExcludingSelf() const;
524
+
525
+ // Advanced memory management --------------------------------------
526
+ // When hardcore memory management becomes necessary -- as it sometimes
527
+ // does here at Google -- the following methods may be useful.
528
+
529
+ // Add an already-allocated object, passing ownership to the
530
+ // RepeatedPtrField.
531
+ void AddAllocated(Element* value);
532
+ // Remove the last element and return it, passing ownership to the caller.
533
+ // Requires: size() > 0
534
+ Element* ReleaseLast();
535
+
536
+ // Extract elements with indices in the range "[start .. start+num-1]".
537
+ // The caller assumes ownership of the extracted elements and is responsible
538
+ // for deleting them when they are no longer needed.
539
+ // If "elements" is non-NULL, then pointers to the extracted elements
540
+ // are stored in "elements[0 .. num-1]" for the convenience of the caller.
541
+ // If "elements" is NULL, then the caller must use some other mechanism
542
+ // to perform any further operations (like deletion) on these elements.
543
+ // Caution: implementation also moves elements with indices [start+num ..].
544
+ // Calling this routine inside a loop can cause quadratic behavior.
545
+ void ExtractSubrange(int start, int num, Element** elements);
546
+
547
+ // When elements are removed by calls to RemoveLast() or Clear(), they
548
+ // are not actually freed. Instead, they are cleared and kept so that
549
+ // they can be reused later. This can save lots of CPU time when
550
+ // repeatedly reusing a protocol message for similar purposes.
551
+ //
552
+ // Hardcore programs may choose to manipulate these cleared objects
553
+ // to better optimize memory management using the following routines.
554
+
555
+ // Get the number of cleared objects that are currently being kept
556
+ // around for reuse.
557
+ int ClearedCount() const;
558
+ // Add an element to the pool of cleared objects, passing ownership to
559
+ // the RepeatedPtrField. The element must be cleared prior to calling
560
+ // this method.
561
+ void AddCleared(Element* value);
562
+ // Remove a single element from the cleared pool and return it, passing
563
+ // ownership to the caller. The element is guaranteed to be cleared.
564
+ // Requires: ClearedCount() > 0
565
+ Element* ReleaseCleared();
566
+
567
+ protected:
568
+ // Note: RepeatedPtrField SHOULD NOT be subclassed by users. We only
569
+ // subclass it in one place as a hack for compatibility with proto1. The
570
+ // subclass needs to know about TypeHandler in order to call protected
571
+ // methods on RepeatedPtrFieldBase.
572
+ class TypeHandler;
573
+
574
+ };
575
+
576
+ // implementation ====================================================
577
+
578
+ template <typename Element>
579
+ inline RepeatedField<Element>::RepeatedField()
580
+ : elements_(NULL),
581
+ current_size_(0),
582
+ total_size_(kInitialSize) {
583
+ }
584
+
585
+ template <typename Element>
586
+ inline RepeatedField<Element>::RepeatedField(const RepeatedField& other)
587
+ : elements_(NULL),
588
+ current_size_(0),
589
+ total_size_(kInitialSize) {
590
+ CopyFrom(other);
591
+ }
592
+
593
+ template <typename Element>
594
+ template <typename Iter>
595
+ inline RepeatedField<Element>::RepeatedField(Iter begin, const Iter& end)
596
+ : elements_(NULL),
597
+ current_size_(0),
598
+ total_size_(kInitialSize) {
599
+ int reserve = internal::CalculateReserve(begin, end);
600
+ if (reserve != -1) {
601
+ Reserve(reserve);
602
+ for (; begin != end; ++begin) {
603
+ AddAlreadyReserved(*begin);
604
+ }
605
+ } else {
606
+ for (; begin != end; ++begin) {
607
+ Add(*begin);
608
+ }
609
+ }
610
+ }
611
+
612
+ template <typename Element>
613
+ RepeatedField<Element>::~RepeatedField() {
614
+ delete [] elements_;
615
+ }
616
+
617
+ template <typename Element>
618
+ inline RepeatedField<Element>&
619
+ RepeatedField<Element>::operator=(const RepeatedField& other) {
620
+ if (this != &other)
621
+ CopyFrom(other);
622
+ return *this;
623
+ }
624
+
625
+ template <typename Element>
626
+ inline bool RepeatedField<Element>::empty() const {
627
+ return current_size_ == 0;
628
+ }
629
+
630
+ template <typename Element>
631
+ inline int RepeatedField<Element>::size() const {
632
+ return current_size_;
633
+ }
634
+
635
+ template <typename Element>
636
+ inline int RepeatedField<Element>::Capacity() const {
637
+ return total_size_;
638
+ }
639
+
640
+ template<typename Element>
641
+ inline void RepeatedField<Element>::AddAlreadyReserved(const Element& value) {
642
+ GOOGLE_DCHECK_LT(size(), Capacity());
643
+ elements_[current_size_++] = value;
644
+ }
645
+
646
+ template<typename Element>
647
+ inline Element* RepeatedField<Element>::AddAlreadyReserved() {
648
+ GOOGLE_DCHECK_LT(size(), Capacity());
649
+ return &elements_[current_size_++];
650
+ }
651
+
652
+ template<typename Element>
653
+ inline void RepeatedField<Element>::Resize(int new_size, const Element& value) {
654
+ GOOGLE_DCHECK_GE(new_size, 0);
655
+ if (new_size > size()) {
656
+ Reserve(new_size);
657
+ std::fill(&elements_[current_size_], &elements_[new_size], value);
658
+ }
659
+ current_size_ = new_size;
660
+ }
661
+
662
+ template <typename Element>
663
+ inline const Element& RepeatedField<Element>::Get(int index) const {
664
+ GOOGLE_DCHECK_GE(index, 0);
665
+ GOOGLE_DCHECK_LT(index, size());
666
+ return elements_[index];
667
+ }
668
+
669
+ template <typename Element>
670
+ inline Element* RepeatedField<Element>::Mutable(int index) {
671
+ GOOGLE_DCHECK_GE(index, 0);
672
+ GOOGLE_DCHECK_LT(index, size());
673
+ return elements_ + index;
674
+ }
675
+
676
+ template <typename Element>
677
+ inline void RepeatedField<Element>::Set(int index, const Element& value) {
678
+ GOOGLE_DCHECK_GE(index, 0);
679
+ GOOGLE_DCHECK_LT(index, size());
680
+ elements_[index] = value;
681
+ }
682
+
683
+ template <typename Element>
684
+ inline void RepeatedField<Element>::Add(const Element& value) {
685
+ if (current_size_ == total_size_) Reserve(total_size_ + 1);
686
+ elements_[current_size_++] = value;
687
+ }
688
+
689
+ template <typename Element>
690
+ inline Element* RepeatedField<Element>::Add() {
691
+ if (current_size_ == total_size_) Reserve(total_size_ + 1);
692
+ return &elements_[current_size_++];
693
+ }
694
+
695
+ template <typename Element>
696
+ inline void RepeatedField<Element>::RemoveLast() {
697
+ GOOGLE_DCHECK_GT(current_size_, 0);
698
+ --current_size_;
699
+ }
700
+
701
+ template <typename Element>
702
+ void RepeatedField<Element>::ExtractSubrange(
703
+ int start, int num, Element* elements) {
704
+ GOOGLE_DCHECK_GE(start, 0);
705
+ GOOGLE_DCHECK_GE(num, 0);
706
+ GOOGLE_DCHECK_LE(start + num, this->size());
707
+
708
+ // Save the values of the removed elements if requested.
709
+ if (elements != NULL) {
710
+ for (int i = 0; i < num; ++i)
711
+ elements[i] = this->Get(i + start);
712
+ }
713
+
714
+ // Slide remaining elements down to fill the gap.
715
+ if (num > 0) {
716
+ for (int i = start + num; i < this->size(); ++i)
717
+ this->Set(i - num, this->Get(i));
718
+ this->Truncate(this->size() - num);
719
+ }
720
+ }
721
+
722
+ template <typename Element>
723
+ inline void RepeatedField<Element>::Clear() {
724
+ current_size_ = 0;
725
+ }
726
+
727
+ template <typename Element>
728
+ inline void RepeatedField<Element>::MergeFrom(const RepeatedField& other) {
729
+ GOOGLE_CHECK_NE(&other, this);
730
+ if (other.current_size_ != 0) {
731
+ Reserve(current_size_ + other.current_size_);
732
+ CopyArray(elements_ + current_size_, other.elements_, other.current_size_);
733
+ current_size_ += other.current_size_;
734
+ }
735
+ }
736
+
737
+ template <typename Element>
738
+ inline void RepeatedField<Element>::CopyFrom(const RepeatedField& other) {
739
+ if (&other == this) return;
740
+ Clear();
741
+ MergeFrom(other);
742
+ }
743
+
744
+ template <typename Element>
745
+ inline Element* RepeatedField<Element>::mutable_data() {
746
+ return elements_;
747
+ }
748
+
749
+ template <typename Element>
750
+ inline const Element* RepeatedField<Element>::data() const {
751
+ return elements_;
752
+ }
753
+
754
+
755
+ template <typename Element>
756
+ void RepeatedField<Element>::Swap(RepeatedField* other) {
757
+ if (this == other) return;
758
+ Element* swap_elements = elements_;
759
+ int swap_current_size = current_size_;
760
+ int swap_total_size = total_size_;
761
+
762
+ elements_ = other->elements_;
763
+ current_size_ = other->current_size_;
764
+ total_size_ = other->total_size_;
765
+
766
+ other->elements_ = swap_elements;
767
+ other->current_size_ = swap_current_size;
768
+ other->total_size_ = swap_total_size;
769
+ }
770
+
771
+ template <typename Element>
772
+ void RepeatedField<Element>::SwapElements(int index1, int index2) {
773
+ using std::swap; // enable ADL with fallback
774
+ swap(elements_[index1], elements_[index2]);
775
+ }
776
+
777
+ template <typename Element>
778
+ inline typename RepeatedField<Element>::iterator
779
+ RepeatedField<Element>::begin() {
780
+ return elements_;
781
+ }
782
+ template <typename Element>
783
+ inline typename RepeatedField<Element>::const_iterator
784
+ RepeatedField<Element>::begin() const {
785
+ return elements_;
786
+ }
787
+ template <typename Element>
788
+ inline typename RepeatedField<Element>::iterator
789
+ RepeatedField<Element>::end() {
790
+ return elements_ + current_size_;
791
+ }
792
+ template <typename Element>
793
+ inline typename RepeatedField<Element>::const_iterator
794
+ RepeatedField<Element>::end() const {
795
+ return elements_ + current_size_;
796
+ }
797
+
798
+ template <typename Element>
799
+ inline int RepeatedField<Element>::SpaceUsedExcludingSelf() const {
800
+ return (elements_ != NULL) ? total_size_ * sizeof(elements_[0]) : 0;
801
+ }
802
+
803
+ // Avoid inlining of Reserve(): new, copy, and delete[] lead to a significant
804
+ // amount of code bloat.
805
+ template <typename Element>
806
+ void RepeatedField<Element>::Reserve(int new_size) {
807
+ if (total_size_ >= new_size) return;
808
+
809
+ Element* old_elements = elements_;
810
+ total_size_ = max(google::protobuf::internal::kMinRepeatedFieldAllocationSize,
811
+ max(total_size_ * 2, new_size));
812
+ elements_ = new Element[total_size_];
813
+ if (old_elements != NULL) {
814
+ MoveArray(elements_, old_elements, current_size_);
815
+ delete [] old_elements;
816
+ }
817
+ }
818
+
819
+ template <typename Element>
820
+ inline void RepeatedField<Element>::Truncate(int new_size) {
821
+ GOOGLE_DCHECK_LE(new_size, current_size_);
822
+ current_size_ = new_size;
823
+ }
824
+
825
+ template <typename Element>
826
+ inline void RepeatedField<Element>::MoveArray(
827
+ Element to[], Element from[], int array_size) {
828
+ CopyArray(to, from, array_size);
829
+ }
830
+
831
+ template <typename Element>
832
+ inline void RepeatedField<Element>::CopyArray(
833
+ Element to[], const Element from[], int array_size) {
834
+ internal::ElementCopier<Element>()(to, from, array_size);
835
+ }
836
+
837
+ namespace internal {
838
+
839
+ template <typename Element, bool HasTrivialCopy>
840
+ void ElementCopier<Element, HasTrivialCopy>::operator()(
841
+ Element to[], const Element from[], int array_size) {
842
+ std::copy(from, from + array_size, to);
843
+ }
844
+
845
+ template <typename Element>
846
+ struct ElementCopier<Element, true> {
847
+ void operator()(Element to[], const Element from[], int array_size) {
848
+ memcpy(to, from, array_size * sizeof(Element));
849
+ }
850
+ };
851
+
852
+ } // namespace internal
853
+
854
+
855
+ // -------------------------------------------------------------------
856
+
857
+ namespace internal {
858
+
859
+ inline RepeatedPtrFieldBase::RepeatedPtrFieldBase()
860
+ : elements_(NULL),
861
+ current_size_(0),
862
+ allocated_size_(0),
863
+ total_size_(kInitialSize) {
864
+ }
865
+
866
+ template <typename TypeHandler>
867
+ void RepeatedPtrFieldBase::Destroy() {
868
+ for (int i = 0; i < allocated_size_; i++) {
869
+ TypeHandler::Delete(cast<TypeHandler>(elements_[i]));
870
+ }
871
+ delete [] elements_;
872
+ }
873
+
874
+ inline bool RepeatedPtrFieldBase::empty() const {
875
+ return current_size_ == 0;
876
+ }
877
+
878
+ inline int RepeatedPtrFieldBase::size() const {
879
+ return current_size_;
880
+ }
881
+
882
+ template <typename TypeHandler>
883
+ inline const typename TypeHandler::Type&
884
+ RepeatedPtrFieldBase::Get(int index) const {
885
+ GOOGLE_DCHECK_GE(index, 0);
886
+ GOOGLE_DCHECK_LT(index, size());
887
+ return *cast<TypeHandler>(elements_[index]);
888
+ }
889
+
890
+
891
+ template <typename TypeHandler>
892
+ inline typename TypeHandler::Type*
893
+ RepeatedPtrFieldBase::Mutable(int index) {
894
+ GOOGLE_DCHECK_GE(index, 0);
895
+ GOOGLE_DCHECK_LT(index, size());
896
+ return cast<TypeHandler>(elements_[index]);
897
+ }
898
+
899
+ template <typename TypeHandler>
900
+ inline typename TypeHandler::Type* RepeatedPtrFieldBase::Add() {
901
+ if (current_size_ < allocated_size_) {
902
+ return cast<TypeHandler>(elements_[current_size_++]);
903
+ }
904
+ if (allocated_size_ == total_size_) Reserve(total_size_ + 1);
905
+ typename TypeHandler::Type* result = TypeHandler::New();
906
+ ++allocated_size_;
907
+ elements_[current_size_++] = result;
908
+ return result;
909
+ }
910
+
911
+ template <typename TypeHandler>
912
+ inline void RepeatedPtrFieldBase::RemoveLast() {
913
+ GOOGLE_DCHECK_GT(current_size_, 0);
914
+ TypeHandler::Clear(cast<TypeHandler>(elements_[--current_size_]));
915
+ }
916
+
917
+ template <typename TypeHandler>
918
+ void RepeatedPtrFieldBase::Clear() {
919
+ for (int i = 0; i < current_size_; i++) {
920
+ TypeHandler::Clear(cast<TypeHandler>(elements_[i]));
921
+ }
922
+ current_size_ = 0;
923
+ }
924
+
925
+ template <typename TypeHandler>
926
+ inline void RepeatedPtrFieldBase::MergeFrom(const RepeatedPtrFieldBase& other) {
927
+ GOOGLE_CHECK_NE(&other, this);
928
+ Reserve(current_size_ + other.current_size_);
929
+ for (int i = 0; i < other.current_size_; i++) {
930
+ TypeHandler::Merge(other.template Get<TypeHandler>(i), Add<TypeHandler>());
931
+ }
932
+ }
933
+
934
+ template <typename TypeHandler>
935
+ inline void RepeatedPtrFieldBase::CopyFrom(const RepeatedPtrFieldBase& other) {
936
+ if (&other == this) return;
937
+ RepeatedPtrFieldBase::Clear<TypeHandler>();
938
+ RepeatedPtrFieldBase::MergeFrom<TypeHandler>(other);
939
+ }
940
+
941
+ inline int RepeatedPtrFieldBase::Capacity() const {
942
+ return total_size_;
943
+ }
944
+
945
+ inline void* const* RepeatedPtrFieldBase::raw_data() const {
946
+ return elements_;
947
+ }
948
+
949
+ inline void** RepeatedPtrFieldBase::raw_mutable_data() const {
950
+ return elements_;
951
+ }
952
+
953
+ template <typename TypeHandler>
954
+ inline typename TypeHandler::Type** RepeatedPtrFieldBase::mutable_data() {
955
+ // TODO(kenton): Breaks C++ aliasing rules. We should probably remove this
956
+ // method entirely.
957
+ return reinterpret_cast<typename TypeHandler::Type**>(elements_);
958
+ }
959
+
960
+ template <typename TypeHandler>
961
+ inline const typename TypeHandler::Type* const*
962
+ RepeatedPtrFieldBase::data() const {
963
+ // TODO(kenton): Breaks C++ aliasing rules. We should probably remove this
964
+ // method entirely.
965
+ return reinterpret_cast<const typename TypeHandler::Type* const*>(elements_);
966
+ }
967
+
968
+ inline void RepeatedPtrFieldBase::SwapElements(int index1, int index2) {
969
+ using std::swap; // enable ADL with fallback
970
+ swap(elements_[index1], elements_[index2]);
971
+ }
972
+
973
+ template <typename TypeHandler>
974
+ inline int RepeatedPtrFieldBase::SpaceUsedExcludingSelf() const {
975
+ int allocated_bytes =
976
+ (elements_ != NULL) ? total_size_ * sizeof(elements_[0]) : 0;
977
+ for (int i = 0; i < allocated_size_; ++i) {
978
+ allocated_bytes += TypeHandler::SpaceUsed(*cast<TypeHandler>(elements_[i]));
979
+ }
980
+ return allocated_bytes;
981
+ }
982
+
983
+ template <typename TypeHandler>
984
+ inline typename TypeHandler::Type* RepeatedPtrFieldBase::AddFromCleared() {
985
+ if (current_size_ < allocated_size_) {
986
+ return cast<TypeHandler>(elements_[current_size_++]);
987
+ } else {
988
+ return NULL;
989
+ }
990
+ }
991
+
992
+ template <typename TypeHandler>
993
+ void RepeatedPtrFieldBase::AddAllocated(
994
+ typename TypeHandler::Type* value) {
995
+ // Make room for the new pointer.
996
+ if (current_size_ == total_size_) {
997
+ // The array is completely full with no cleared objects, so grow it.
998
+ Reserve(total_size_ + 1);
999
+ ++allocated_size_;
1000
+ } else if (allocated_size_ == total_size_) {
1001
+ // There is no more space in the pointer array because it contains some
1002
+ // cleared objects awaiting reuse. We don't want to grow the array in this
1003
+ // case because otherwise a loop calling AddAllocated() followed by Clear()
1004
+ // would leak memory.
1005
+ TypeHandler::Delete(cast<TypeHandler>(elements_[current_size_]));
1006
+ } else if (current_size_ < allocated_size_) {
1007
+ // We have some cleared objects. We don't care about their order, so we
1008
+ // can just move the first one to the end to make space.
1009
+ elements_[allocated_size_] = elements_[current_size_];
1010
+ ++allocated_size_;
1011
+ } else {
1012
+ // There are no cleared objects.
1013
+ ++allocated_size_;
1014
+ }
1015
+
1016
+ elements_[current_size_++] = value;
1017
+ }
1018
+
1019
+ template <typename TypeHandler>
1020
+ inline typename TypeHandler::Type* RepeatedPtrFieldBase::ReleaseLast() {
1021
+ GOOGLE_DCHECK_GT(current_size_, 0);
1022
+ typename TypeHandler::Type* result =
1023
+ cast<TypeHandler>(elements_[--current_size_]);
1024
+ --allocated_size_;
1025
+ if (current_size_ < allocated_size_) {
1026
+ // There are cleared elements on the end; replace the removed element
1027
+ // with the last allocated element.
1028
+ elements_[current_size_] = elements_[allocated_size_];
1029
+ }
1030
+ return result;
1031
+ }
1032
+
1033
+ inline int RepeatedPtrFieldBase::ClearedCount() const {
1034
+ return allocated_size_ - current_size_;
1035
+ }
1036
+
1037
+ template <typename TypeHandler>
1038
+ inline void RepeatedPtrFieldBase::AddCleared(
1039
+ typename TypeHandler::Type* value) {
1040
+ if (allocated_size_ == total_size_) Reserve(total_size_ + 1);
1041
+ elements_[allocated_size_++] = value;
1042
+ }
1043
+
1044
+ template <typename TypeHandler>
1045
+ inline typename TypeHandler::Type* RepeatedPtrFieldBase::ReleaseCleared() {
1046
+ GOOGLE_DCHECK_GT(allocated_size_, current_size_);
1047
+ return cast<TypeHandler>(elements_[--allocated_size_]);
1048
+ }
1049
+
1050
+ } // namespace internal
1051
+
1052
+ // -------------------------------------------------------------------
1053
+
1054
+ template <typename Element>
1055
+ class RepeatedPtrField<Element>::TypeHandler
1056
+ : public internal::GenericTypeHandler<Element> {
1057
+ };
1058
+
1059
+ template <>
1060
+ class RepeatedPtrField<string>::TypeHandler
1061
+ : public internal::StringTypeHandler {
1062
+ };
1063
+
1064
+
1065
+ template <typename Element>
1066
+ inline RepeatedPtrField<Element>::RepeatedPtrField() {}
1067
+
1068
+ template <typename Element>
1069
+ inline RepeatedPtrField<Element>::RepeatedPtrField(
1070
+ const RepeatedPtrField& other)
1071
+ : RepeatedPtrFieldBase() {
1072
+ CopyFrom(other);
1073
+ }
1074
+
1075
+ template <typename Element>
1076
+ template <typename Iter>
1077
+ inline RepeatedPtrField<Element>::RepeatedPtrField(
1078
+ Iter begin, const Iter& end) {
1079
+ int reserve = internal::CalculateReserve(begin, end);
1080
+ if (reserve != -1) {
1081
+ Reserve(reserve);
1082
+ }
1083
+ for (; begin != end; ++begin) {
1084
+ *Add() = *begin;
1085
+ }
1086
+ }
1087
+
1088
+ template <typename Element>
1089
+ RepeatedPtrField<Element>::~RepeatedPtrField() {
1090
+ Destroy<TypeHandler>();
1091
+ }
1092
+
1093
+ template <typename Element>
1094
+ inline RepeatedPtrField<Element>& RepeatedPtrField<Element>::operator=(
1095
+ const RepeatedPtrField& other) {
1096
+ if (this != &other)
1097
+ CopyFrom(other);
1098
+ return *this;
1099
+ }
1100
+
1101
+ template <typename Element>
1102
+ inline bool RepeatedPtrField<Element>::empty() const {
1103
+ return RepeatedPtrFieldBase::empty();
1104
+ }
1105
+
1106
+ template <typename Element>
1107
+ inline int RepeatedPtrField<Element>::size() const {
1108
+ return RepeatedPtrFieldBase::size();
1109
+ }
1110
+
1111
+ template <typename Element>
1112
+ inline const Element& RepeatedPtrField<Element>::Get(int index) const {
1113
+ return RepeatedPtrFieldBase::Get<TypeHandler>(index);
1114
+ }
1115
+
1116
+
1117
+ template <typename Element>
1118
+ inline Element* RepeatedPtrField<Element>::Mutable(int index) {
1119
+ return RepeatedPtrFieldBase::Mutable<TypeHandler>(index);
1120
+ }
1121
+
1122
+ template <typename Element>
1123
+ inline Element* RepeatedPtrField<Element>::Add() {
1124
+ return RepeatedPtrFieldBase::Add<TypeHandler>();
1125
+ }
1126
+
1127
+ template <typename Element>
1128
+ inline void RepeatedPtrField<Element>::RemoveLast() {
1129
+ RepeatedPtrFieldBase::RemoveLast<TypeHandler>();
1130
+ }
1131
+
1132
+ template <typename Element>
1133
+ inline void RepeatedPtrField<Element>::DeleteSubrange(int start, int num) {
1134
+ GOOGLE_DCHECK_GE(start, 0);
1135
+ GOOGLE_DCHECK_GE(num, 0);
1136
+ GOOGLE_DCHECK_LE(start + num, size());
1137
+ for (int i = 0; i < num; ++i)
1138
+ delete RepeatedPtrFieldBase::Mutable<TypeHandler>(start + i);
1139
+ ExtractSubrange(start, num, NULL);
1140
+ }
1141
+
1142
+ template <typename Element>
1143
+ inline void RepeatedPtrField<Element>::ExtractSubrange(
1144
+ int start, int num, Element** elements) {
1145
+ GOOGLE_DCHECK_GE(start, 0);
1146
+ GOOGLE_DCHECK_GE(num, 0);
1147
+ GOOGLE_DCHECK_LE(start + num, size());
1148
+
1149
+ if (num > 0) {
1150
+ // Save the values of the removed elements if requested.
1151
+ if (elements != NULL) {
1152
+ for (int i = 0; i < num; ++i)
1153
+ elements[i] = RepeatedPtrFieldBase::Mutable<TypeHandler>(i + start);
1154
+ }
1155
+ CloseGap(start, num);
1156
+ }
1157
+ }
1158
+
1159
+ template <typename Element>
1160
+ inline void RepeatedPtrField<Element>::Clear() {
1161
+ RepeatedPtrFieldBase::Clear<TypeHandler>();
1162
+ }
1163
+
1164
+ template <typename Element>
1165
+ inline void RepeatedPtrField<Element>::MergeFrom(
1166
+ const RepeatedPtrField& other) {
1167
+ RepeatedPtrFieldBase::MergeFrom<TypeHandler>(other);
1168
+ }
1169
+
1170
+ template <typename Element>
1171
+ inline void RepeatedPtrField<Element>::CopyFrom(
1172
+ const RepeatedPtrField& other) {
1173
+ RepeatedPtrFieldBase::CopyFrom<TypeHandler>(other);
1174
+ }
1175
+
1176
+ template <typename Element>
1177
+ inline Element** RepeatedPtrField<Element>::mutable_data() {
1178
+ return RepeatedPtrFieldBase::mutable_data<TypeHandler>();
1179
+ }
1180
+
1181
+ template <typename Element>
1182
+ inline const Element* const* RepeatedPtrField<Element>::data() const {
1183
+ return RepeatedPtrFieldBase::data<TypeHandler>();
1184
+ }
1185
+
1186
+ template <typename Element>
1187
+ void RepeatedPtrField<Element>::Swap(RepeatedPtrField* other) {
1188
+ RepeatedPtrFieldBase::Swap(other);
1189
+ }
1190
+
1191
+ template <typename Element>
1192
+ void RepeatedPtrField<Element>::SwapElements(int index1, int index2) {
1193
+ RepeatedPtrFieldBase::SwapElements(index1, index2);
1194
+ }
1195
+
1196
+ template <typename Element>
1197
+ inline int RepeatedPtrField<Element>::SpaceUsedExcludingSelf() const {
1198
+ return RepeatedPtrFieldBase::SpaceUsedExcludingSelf<TypeHandler>();
1199
+ }
1200
+
1201
+ template <typename Element>
1202
+ inline void RepeatedPtrField<Element>::AddAllocated(Element* value) {
1203
+ RepeatedPtrFieldBase::AddAllocated<TypeHandler>(value);
1204
+ }
1205
+
1206
+ template <typename Element>
1207
+ inline Element* RepeatedPtrField<Element>::ReleaseLast() {
1208
+ return RepeatedPtrFieldBase::ReleaseLast<TypeHandler>();
1209
+ }
1210
+
1211
+
1212
+ template <typename Element>
1213
+ inline int RepeatedPtrField<Element>::ClearedCount() const {
1214
+ return RepeatedPtrFieldBase::ClearedCount();
1215
+ }
1216
+
1217
+ template <typename Element>
1218
+ inline void RepeatedPtrField<Element>::AddCleared(Element* value) {
1219
+ return RepeatedPtrFieldBase::AddCleared<TypeHandler>(value);
1220
+ }
1221
+
1222
+ template <typename Element>
1223
+ inline Element* RepeatedPtrField<Element>::ReleaseCleared() {
1224
+ return RepeatedPtrFieldBase::ReleaseCleared<TypeHandler>();
1225
+ }
1226
+
1227
+ template <typename Element>
1228
+ inline void RepeatedPtrField<Element>::Reserve(int new_size) {
1229
+ return RepeatedPtrFieldBase::Reserve(new_size);
1230
+ }
1231
+
1232
+ template <typename Element>
1233
+ inline int RepeatedPtrField<Element>::Capacity() const {
1234
+ return RepeatedPtrFieldBase::Capacity();
1235
+ }
1236
+
1237
+ // -------------------------------------------------------------------
1238
+
1239
+ namespace internal {
1240
+
1241
+ // STL-like iterator implementation for RepeatedPtrField. You should not
1242
+ // refer to this class directly; use RepeatedPtrField<T>::iterator instead.
1243
+ //
1244
+ // The iterator for RepeatedPtrField<T>, RepeatedPtrIterator<T>, is
1245
+ // very similar to iterator_ptr<T**> in util/gtl/iterator_adaptors.h,
1246
+ // but adds random-access operators and is modified to wrap a void** base
1247
+ // iterator (since RepeatedPtrField stores its array as a void* array and
1248
+ // casting void** to T** would violate C++ aliasing rules).
1249
+ //
1250
+ // This code based on net/proto/proto-array-internal.h by Jeffrey Yasskin
1251
+ // (jyasskin@google.com).
1252
+ template<typename Element>
1253
+ class RepeatedPtrIterator
1254
+ : public std::iterator<
1255
+ std::random_access_iterator_tag, Element> {
1256
+ public:
1257
+ typedef RepeatedPtrIterator<Element> iterator;
1258
+ typedef std::iterator<
1259
+ std::random_access_iterator_tag, Element> superclass;
1260
+
1261
+ // Shadow the value_type in std::iterator<> because const_iterator::value_type
1262
+ // needs to be T, not const T.
1263
+ typedef typename remove_const<Element>::type value_type;
1264
+
1265
+ // Let the compiler know that these are type names, so we don't have to
1266
+ // write "typename" in front of them everywhere.
1267
+ typedef typename superclass::reference reference;
1268
+ typedef typename superclass::pointer pointer;
1269
+ typedef typename superclass::difference_type difference_type;
1270
+
1271
+ RepeatedPtrIterator() : it_(NULL) {}
1272
+ explicit RepeatedPtrIterator(void* const* it) : it_(it) {}
1273
+
1274
+ // Allow "upcasting" from RepeatedPtrIterator<T**> to
1275
+ // RepeatedPtrIterator<const T*const*>.
1276
+ template<typename OtherElement>
1277
+ RepeatedPtrIterator(const RepeatedPtrIterator<OtherElement>& other)
1278
+ : it_(other.it_) {
1279
+ // Force a compiler error if the other type is not convertible to ours.
1280
+ if (false) {
1281
+ implicit_cast<Element*, OtherElement*>(0);
1282
+ }
1283
+ }
1284
+
1285
+ // dereferenceable
1286
+ reference operator*() const { return *reinterpret_cast<Element*>(*it_); }
1287
+ pointer operator->() const { return &(operator*()); }
1288
+
1289
+ // {inc,dec}rementable
1290
+ iterator& operator++() { ++it_; return *this; }
1291
+ iterator operator++(int) { return iterator(it_++); }
1292
+ iterator& operator--() { --it_; return *this; }
1293
+ iterator operator--(int) { return iterator(it_--); }
1294
+
1295
+ // equality_comparable
1296
+ bool operator==(const iterator& x) const { return it_ == x.it_; }
1297
+ bool operator!=(const iterator& x) const { return it_ != x.it_; }
1298
+
1299
+ // less_than_comparable
1300
+ bool operator<(const iterator& x) const { return it_ < x.it_; }
1301
+ bool operator<=(const iterator& x) const { return it_ <= x.it_; }
1302
+ bool operator>(const iterator& x) const { return it_ > x.it_; }
1303
+ bool operator>=(const iterator& x) const { return it_ >= x.it_; }
1304
+
1305
+ // addable, subtractable
1306
+ iterator& operator+=(difference_type d) {
1307
+ it_ += d;
1308
+ return *this;
1309
+ }
1310
+ friend iterator operator+(iterator it, difference_type d) {
1311
+ it += d;
1312
+ return it;
1313
+ }
1314
+ friend iterator operator+(difference_type d, iterator it) {
1315
+ it += d;
1316
+ return it;
1317
+ }
1318
+ iterator& operator-=(difference_type d) {
1319
+ it_ -= d;
1320
+ return *this;
1321
+ }
1322
+ friend iterator operator-(iterator it, difference_type d) {
1323
+ it -= d;
1324
+ return it;
1325
+ }
1326
+
1327
+ // indexable
1328
+ reference operator[](difference_type d) const { return *(*this + d); }
1329
+
1330
+ // random access iterator
1331
+ difference_type operator-(const iterator& x) const { return it_ - x.it_; }
1332
+
1333
+ private:
1334
+ template<typename OtherElement>
1335
+ friend class RepeatedPtrIterator;
1336
+
1337
+ // The internal iterator.
1338
+ void* const* it_;
1339
+ };
1340
+
1341
+ // Provide an iterator that operates on pointers to the underlying objects
1342
+ // rather than the objects themselves as RepeatedPtrIterator does.
1343
+ // Consider using this when working with stl algorithms that change
1344
+ // the array.
1345
+ // The VoidPtr template parameter holds the type-agnostic pointer value
1346
+ // referenced by the iterator. It should either be "void *" for a mutable
1347
+ // iterator, or "const void *" for a constant iterator.
1348
+ template<typename Element, typename VoidPtr>
1349
+ class RepeatedPtrOverPtrsIterator
1350
+ : public std::iterator<std::random_access_iterator_tag, Element*> {
1351
+ public:
1352
+ typedef RepeatedPtrOverPtrsIterator<Element, VoidPtr> iterator;
1353
+ typedef std::iterator<
1354
+ std::random_access_iterator_tag, Element*> superclass;
1355
+
1356
+ // Shadow the value_type in std::iterator<> because const_iterator::value_type
1357
+ // needs to be T, not const T.
1358
+ typedef typename remove_const<Element*>::type value_type;
1359
+
1360
+ // Let the compiler know that these are type names, so we don't have to
1361
+ // write "typename" in front of them everywhere.
1362
+ typedef typename superclass::reference reference;
1363
+ typedef typename superclass::pointer pointer;
1364
+ typedef typename superclass::difference_type difference_type;
1365
+
1366
+ RepeatedPtrOverPtrsIterator() : it_(NULL) {}
1367
+ explicit RepeatedPtrOverPtrsIterator(VoidPtr* it) : it_(it) {}
1368
+
1369
+ // dereferenceable
1370
+ reference operator*() const { return *reinterpret_cast<Element**>(it_); }
1371
+ pointer operator->() const { return &(operator*()); }
1372
+
1373
+ // {inc,dec}rementable
1374
+ iterator& operator++() { ++it_; return *this; }
1375
+ iterator operator++(int) { return iterator(it_++); }
1376
+ iterator& operator--() { --it_; return *this; }
1377
+ iterator operator--(int) { return iterator(it_--); }
1378
+
1379
+ // equality_comparable
1380
+ bool operator==(const iterator& x) const { return it_ == x.it_; }
1381
+ bool operator!=(const iterator& x) const { return it_ != x.it_; }
1382
+
1383
+ // less_than_comparable
1384
+ bool operator<(const iterator& x) const { return it_ < x.it_; }
1385
+ bool operator<=(const iterator& x) const { return it_ <= x.it_; }
1386
+ bool operator>(const iterator& x) const { return it_ > x.it_; }
1387
+ bool operator>=(const iterator& x) const { return it_ >= x.it_; }
1388
+
1389
+ // addable, subtractable
1390
+ iterator& operator+=(difference_type d) {
1391
+ it_ += d;
1392
+ return *this;
1393
+ }
1394
+ friend iterator operator+(iterator it, difference_type d) {
1395
+ it += d;
1396
+ return it;
1397
+ }
1398
+ friend iterator operator+(difference_type d, iterator it) {
1399
+ it += d;
1400
+ return it;
1401
+ }
1402
+ iterator& operator-=(difference_type d) {
1403
+ it_ -= d;
1404
+ return *this;
1405
+ }
1406
+ friend iterator operator-(iterator it, difference_type d) {
1407
+ it -= d;
1408
+ return it;
1409
+ }
1410
+
1411
+ // indexable
1412
+ reference operator[](difference_type d) const { return *(*this + d); }
1413
+
1414
+ // random access iterator
1415
+ difference_type operator-(const iterator& x) const { return it_ - x.it_; }
1416
+
1417
+ private:
1418
+ template<typename OtherElement>
1419
+ friend class RepeatedPtrIterator;
1420
+
1421
+ // The internal iterator.
1422
+ VoidPtr* it_;
1423
+ };
1424
+
1425
+ } // namespace internal
1426
+
1427
+ template <typename Element>
1428
+ inline typename RepeatedPtrField<Element>::iterator
1429
+ RepeatedPtrField<Element>::begin() {
1430
+ return iterator(raw_data());
1431
+ }
1432
+ template <typename Element>
1433
+ inline typename RepeatedPtrField<Element>::const_iterator
1434
+ RepeatedPtrField<Element>::begin() const {
1435
+ return iterator(raw_data());
1436
+ }
1437
+ template <typename Element>
1438
+ inline typename RepeatedPtrField<Element>::iterator
1439
+ RepeatedPtrField<Element>::end() {
1440
+ return iterator(raw_data() + size());
1441
+ }
1442
+ template <typename Element>
1443
+ inline typename RepeatedPtrField<Element>::const_iterator
1444
+ RepeatedPtrField<Element>::end() const {
1445
+ return iterator(raw_data() + size());
1446
+ }
1447
+
1448
+ template <typename Element>
1449
+ inline typename RepeatedPtrField<Element>::pointer_iterator
1450
+ RepeatedPtrField<Element>::pointer_begin() {
1451
+ return pointer_iterator(raw_mutable_data());
1452
+ }
1453
+ template <typename Element>
1454
+ inline typename RepeatedPtrField<Element>::const_pointer_iterator
1455
+ RepeatedPtrField<Element>::pointer_begin() const {
1456
+ return const_pointer_iterator(const_cast<const void**>(raw_mutable_data()));
1457
+ }
1458
+ template <typename Element>
1459
+ inline typename RepeatedPtrField<Element>::pointer_iterator
1460
+ RepeatedPtrField<Element>::pointer_end() {
1461
+ return pointer_iterator(raw_mutable_data() + size());
1462
+ }
1463
+ template <typename Element>
1464
+ inline typename RepeatedPtrField<Element>::const_pointer_iterator
1465
+ RepeatedPtrField<Element>::pointer_end() const {
1466
+ return const_pointer_iterator(
1467
+ const_cast<const void**>(raw_mutable_data() + size()));
1468
+ }
1469
+
1470
+
1471
+ // Iterators and helper functions that follow the spirit of the STL
1472
+ // std::back_insert_iterator and std::back_inserter but are tailor-made
1473
+ // for RepeatedField and RepatedPtrField. Typical usage would be:
1474
+ //
1475
+ // std::copy(some_sequence.begin(), some_sequence.end(),
1476
+ // google::protobuf::RepeatedFieldBackInserter(proto.mutable_sequence()));
1477
+ //
1478
+ // Ported by johannes from util/gtl/proto-array-iterators.h
1479
+
1480
+ namespace internal {
1481
+ // A back inserter for RepeatedField objects.
1482
+ template<typename T> class RepeatedFieldBackInsertIterator
1483
+ : public std::iterator<std::output_iterator_tag, T> {
1484
+ public:
1485
+ explicit RepeatedFieldBackInsertIterator(
1486
+ RepeatedField<T>* const mutable_field)
1487
+ : field_(mutable_field) {
1488
+ }
1489
+ RepeatedFieldBackInsertIterator<T>& operator=(const T& value) {
1490
+ field_->Add(value);
1491
+ return *this;
1492
+ }
1493
+ RepeatedFieldBackInsertIterator<T>& operator*() {
1494
+ return *this;
1495
+ }
1496
+ RepeatedFieldBackInsertIterator<T>& operator++() {
1497
+ return *this;
1498
+ }
1499
+ RepeatedFieldBackInsertIterator<T>& operator++(int /* unused */) {
1500
+ return *this;
1501
+ }
1502
+
1503
+ private:
1504
+ RepeatedField<T>* field_;
1505
+ };
1506
+
1507
+ // A back inserter for RepeatedPtrField objects.
1508
+ template<typename T> class RepeatedPtrFieldBackInsertIterator
1509
+ : public std::iterator<std::output_iterator_tag, T> {
1510
+ public:
1511
+ RepeatedPtrFieldBackInsertIterator(
1512
+ RepeatedPtrField<T>* const mutable_field)
1513
+ : field_(mutable_field) {
1514
+ }
1515
+ RepeatedPtrFieldBackInsertIterator<T>& operator=(const T& value) {
1516
+ *field_->Add() = value;
1517
+ return *this;
1518
+ }
1519
+ RepeatedPtrFieldBackInsertIterator<T>& operator=(
1520
+ const T* const ptr_to_value) {
1521
+ *field_->Add() = *ptr_to_value;
1522
+ return *this;
1523
+ }
1524
+ RepeatedPtrFieldBackInsertIterator<T>& operator*() {
1525
+ return *this;
1526
+ }
1527
+ RepeatedPtrFieldBackInsertIterator<T>& operator++() {
1528
+ return *this;
1529
+ }
1530
+ RepeatedPtrFieldBackInsertIterator<T>& operator++(int /* unused */) {
1531
+ return *this;
1532
+ }
1533
+
1534
+ private:
1535
+ RepeatedPtrField<T>* field_;
1536
+ };
1537
+
1538
+ // A back inserter for RepeatedPtrFields that inserts by transfering ownership
1539
+ // of a pointer.
1540
+ template<typename T> class AllocatedRepeatedPtrFieldBackInsertIterator
1541
+ : public std::iterator<std::output_iterator_tag, T> {
1542
+ public:
1543
+ explicit AllocatedRepeatedPtrFieldBackInsertIterator(
1544
+ RepeatedPtrField<T>* const mutable_field)
1545
+ : field_(mutable_field) {
1546
+ }
1547
+ AllocatedRepeatedPtrFieldBackInsertIterator<T>& operator=(
1548
+ T* const ptr_to_value) {
1549
+ field_->AddAllocated(ptr_to_value);
1550
+ return *this;
1551
+ }
1552
+ AllocatedRepeatedPtrFieldBackInsertIterator<T>& operator*() {
1553
+ return *this;
1554
+ }
1555
+ AllocatedRepeatedPtrFieldBackInsertIterator<T>& operator++() {
1556
+ return *this;
1557
+ }
1558
+ AllocatedRepeatedPtrFieldBackInsertIterator<T>& operator++(
1559
+ int /* unused */) {
1560
+ return *this;
1561
+ }
1562
+
1563
+ private:
1564
+ RepeatedPtrField<T>* field_;
1565
+ };
1566
+ } // namespace internal
1567
+
1568
+ // Provides a back insert iterator for RepeatedField instances,
1569
+ // similar to std::back_inserter().
1570
+ template<typename T> internal::RepeatedFieldBackInsertIterator<T>
1571
+ RepeatedFieldBackInserter(RepeatedField<T>* const mutable_field) {
1572
+ return internal::RepeatedFieldBackInsertIterator<T>(mutable_field);
1573
+ }
1574
+
1575
+ // Provides a back insert iterator for RepeatedPtrField instances,
1576
+ // similar to std::back_inserter().
1577
+ template<typename T> internal::RepeatedPtrFieldBackInsertIterator<T>
1578
+ RepeatedPtrFieldBackInserter(RepeatedPtrField<T>* const mutable_field) {
1579
+ return internal::RepeatedPtrFieldBackInsertIterator<T>(mutable_field);
1580
+ }
1581
+
1582
+ // Special back insert iterator for RepeatedPtrField instances, just in
1583
+ // case someone wants to write generic template code that can access both
1584
+ // RepeatedFields and RepeatedPtrFields using a common name.
1585
+ template<typename T> internal::RepeatedPtrFieldBackInsertIterator<T>
1586
+ RepeatedFieldBackInserter(RepeatedPtrField<T>* const mutable_field) {
1587
+ return internal::RepeatedPtrFieldBackInsertIterator<T>(mutable_field);
1588
+ }
1589
+
1590
+ // Provides a back insert iterator for RepeatedPtrField instances
1591
+ // similar to std::back_inserter() which transfers the ownership while
1592
+ // copying elements.
1593
+ template<typename T> internal::AllocatedRepeatedPtrFieldBackInsertIterator<T>
1594
+ AllocatedRepeatedPtrFieldBackInserter(
1595
+ RepeatedPtrField<T>* const mutable_field) {
1596
+ return internal::AllocatedRepeatedPtrFieldBackInsertIterator<T>(
1597
+ mutable_field);
1598
+ }
1599
+
1600
+ } // namespace protobuf
1601
+
1602
+ } // namespace google
1603
+ #endif // GOOGLE_PROTOBUF_REPEATED_FIELD_H__