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,354 @@
1
+ // Protocol Buffers - Google's data interchange format
2
+ // Copyright 2008 Google Inc. All rights reserved.
3
+ // https://developers.google.com/protocol-buffers/
4
+ //
5
+ // Redistribution and use in source and binary forms, with or without
6
+ // modification, are permitted provided that the following conditions are
7
+ // met:
8
+ //
9
+ // * Redistributions of source code must retain the above copyright
10
+ // notice, this list of conditions and the following disclaimer.
11
+ // * Redistributions in binary form must reproduce the above
12
+ // copyright notice, this list of conditions and the following disclaimer
13
+ // in the documentation and/or other materials provided with the
14
+ // distribution.
15
+ // * Neither the name of Google Inc. nor the names of its
16
+ // contributors may be used to endorse or promote products derived from
17
+ // this software without specific prior written permission.
18
+ //
19
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+
31
+ // Author: kenton@google.com (Kenton Varda)
32
+ // Based on original Protocol Buffers design by
33
+ // Sanjay Ghemawat, Jeff Dean, and others.
34
+ //
35
+ // This file contains common implementations of the interfaces defined in
36
+ // zero_copy_stream.h which are included in the "lite" protobuf library.
37
+ // These implementations cover I/O on raw arrays and strings, as well as
38
+ // adaptors which make it easy to implement streams based on traditional
39
+ // streams. Of course, many users will probably want to write their own
40
+ // implementations of these interfaces specific to the particular I/O
41
+ // abstractions they prefer to use, but these should cover the most common
42
+ // cases.
43
+
44
+ #ifndef GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_LITE_H__
45
+ #define GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_LITE_H__
46
+
47
+ #include <string>
48
+ #include <iosfwd>
49
+ #include <google/protobuf/io/zero_copy_stream.h>
50
+ #include <google/protobuf/stubs/common.h>
51
+ #include <google/protobuf/stubs/stl_util.h>
52
+
53
+
54
+ namespace google {
55
+ namespace protobuf {
56
+ namespace io {
57
+
58
+ // ===================================================================
59
+
60
+ // A ZeroCopyInputStream backed by an in-memory array of bytes.
61
+ class LIBPROTOBUF_EXPORT ArrayInputStream : public ZeroCopyInputStream {
62
+ public:
63
+ // Create an InputStream that returns the bytes pointed to by "data".
64
+ // "data" remains the property of the caller but must remain valid until
65
+ // the stream is destroyed. If a block_size is given, calls to Next()
66
+ // will return data blocks no larger than the given size. Otherwise, the
67
+ // first call to Next() returns the entire array. block_size is mainly
68
+ // useful for testing; in production you would probably never want to set
69
+ // it.
70
+ ArrayInputStream(const void* data, int size, int block_size = -1);
71
+ ~ArrayInputStream();
72
+
73
+ // implements ZeroCopyInputStream ----------------------------------
74
+ bool Next(const void** data, int* size);
75
+ void BackUp(int count);
76
+ bool Skip(int count);
77
+ int64 ByteCount() const;
78
+
79
+
80
+ private:
81
+ const uint8* const data_; // The byte array.
82
+ const int size_; // Total size of the array.
83
+ const int block_size_; // How many bytes to return at a time.
84
+
85
+ int position_;
86
+ int last_returned_size_; // How many bytes we returned last time Next()
87
+ // was called (used for error checking only).
88
+
89
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ArrayInputStream);
90
+ };
91
+
92
+ // ===================================================================
93
+
94
+ // A ZeroCopyOutputStream backed by an in-memory array of bytes.
95
+ class LIBPROTOBUF_EXPORT ArrayOutputStream : public ZeroCopyOutputStream {
96
+ public:
97
+ // Create an OutputStream that writes to the bytes pointed to by "data".
98
+ // "data" remains the property of the caller but must remain valid until
99
+ // the stream is destroyed. If a block_size is given, calls to Next()
100
+ // will return data blocks no larger than the given size. Otherwise, the
101
+ // first call to Next() returns the entire array. block_size is mainly
102
+ // useful for testing; in production you would probably never want to set
103
+ // it.
104
+ ArrayOutputStream(void* data, int size, int block_size = -1);
105
+ ~ArrayOutputStream();
106
+
107
+ // implements ZeroCopyOutputStream ---------------------------------
108
+ bool Next(void** data, int* size);
109
+ void BackUp(int count);
110
+ int64 ByteCount() const;
111
+
112
+ private:
113
+ uint8* const data_; // The byte array.
114
+ const int size_; // Total size of the array.
115
+ const int block_size_; // How many bytes to return at a time.
116
+
117
+ int position_;
118
+ int last_returned_size_; // How many bytes we returned last time Next()
119
+ // was called (used for error checking only).
120
+
121
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ArrayOutputStream);
122
+ };
123
+
124
+ // ===================================================================
125
+
126
+ // A ZeroCopyOutputStream which appends bytes to a string.
127
+ class LIBPROTOBUF_EXPORT StringOutputStream : public ZeroCopyOutputStream {
128
+ public:
129
+ // Create a StringOutputStream which appends bytes to the given string.
130
+ // The string remains property of the caller, but it MUST NOT be accessed
131
+ // in any way until the stream is destroyed.
132
+ //
133
+ // Hint: If you call target->reserve(n) before creating the stream,
134
+ // the first call to Next() will return at least n bytes of buffer
135
+ // space.
136
+ explicit StringOutputStream(string* target);
137
+ ~StringOutputStream();
138
+
139
+ // implements ZeroCopyOutputStream ---------------------------------
140
+ bool Next(void** data, int* size);
141
+ void BackUp(int count);
142
+ int64 ByteCount() const;
143
+
144
+ private:
145
+ static const int kMinimumSize = 16;
146
+
147
+ string* target_;
148
+
149
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringOutputStream);
150
+ };
151
+
152
+ // Note: There is no StringInputStream. Instead, just create an
153
+ // ArrayInputStream as follows:
154
+ // ArrayInputStream input(str.data(), str.size());
155
+
156
+ // ===================================================================
157
+
158
+ // A generic traditional input stream interface.
159
+ //
160
+ // Lots of traditional input streams (e.g. file descriptors, C stdio
161
+ // streams, and C++ iostreams) expose an interface where every read
162
+ // involves copying bytes into a buffer. If you want to take such an
163
+ // interface and make a ZeroCopyInputStream based on it, simply implement
164
+ // CopyingInputStream and then use CopyingInputStreamAdaptor.
165
+ //
166
+ // CopyingInputStream implementations should avoid buffering if possible.
167
+ // CopyingInputStreamAdaptor does its own buffering and will read data
168
+ // in large blocks.
169
+ class LIBPROTOBUF_EXPORT CopyingInputStream {
170
+ public:
171
+ virtual ~CopyingInputStream();
172
+
173
+ // Reads up to "size" bytes into the given buffer. Returns the number of
174
+ // bytes read. Read() waits until at least one byte is available, or
175
+ // returns zero if no bytes will ever become available (EOF), or -1 if a
176
+ // permanent read error occurred.
177
+ virtual int Read(void* buffer, int size) = 0;
178
+
179
+ // Skips the next "count" bytes of input. Returns the number of bytes
180
+ // actually skipped. This will always be exactly equal to "count" unless
181
+ // EOF was reached or a permanent read error occurred.
182
+ //
183
+ // The default implementation just repeatedly calls Read() into a scratch
184
+ // buffer.
185
+ virtual int Skip(int count);
186
+ };
187
+
188
+ // A ZeroCopyInputStream which reads from a CopyingInputStream. This is
189
+ // useful for implementing ZeroCopyInputStreams that read from traditional
190
+ // streams. Note that this class is not really zero-copy.
191
+ //
192
+ // If you want to read from file descriptors or C++ istreams, this is
193
+ // already implemented for you: use FileInputStream or IstreamInputStream
194
+ // respectively.
195
+ class LIBPROTOBUF_EXPORT CopyingInputStreamAdaptor : public ZeroCopyInputStream {
196
+ public:
197
+ // Creates a stream that reads from the given CopyingInputStream.
198
+ // If a block_size is given, it specifies the number of bytes that
199
+ // should be read and returned with each call to Next(). Otherwise,
200
+ // a reasonable default is used. The caller retains ownership of
201
+ // copying_stream unless SetOwnsCopyingStream(true) is called.
202
+ explicit CopyingInputStreamAdaptor(CopyingInputStream* copying_stream,
203
+ int block_size = -1);
204
+ ~CopyingInputStreamAdaptor();
205
+
206
+ // Call SetOwnsCopyingStream(true) to tell the CopyingInputStreamAdaptor to
207
+ // delete the underlying CopyingInputStream when it is destroyed.
208
+ void SetOwnsCopyingStream(bool value) { owns_copying_stream_ = value; }
209
+
210
+ // implements ZeroCopyInputStream ----------------------------------
211
+ bool Next(const void** data, int* size);
212
+ void BackUp(int count);
213
+ bool Skip(int count);
214
+ int64 ByteCount() const;
215
+
216
+ private:
217
+ // Insures that buffer_ is not NULL.
218
+ void AllocateBufferIfNeeded();
219
+ // Frees the buffer and resets buffer_used_.
220
+ void FreeBuffer();
221
+
222
+ // The underlying copying stream.
223
+ CopyingInputStream* copying_stream_;
224
+ bool owns_copying_stream_;
225
+
226
+ // True if we have seen a permenant error from the underlying stream.
227
+ bool failed_;
228
+
229
+ // The current position of copying_stream_, relative to the point where
230
+ // we started reading.
231
+ int64 position_;
232
+
233
+ // Data is read into this buffer. It may be NULL if no buffer is currently
234
+ // in use. Otherwise, it points to an array of size buffer_size_.
235
+ scoped_array<uint8> buffer_;
236
+ const int buffer_size_;
237
+
238
+ // Number of valid bytes currently in the buffer (i.e. the size last
239
+ // returned by Next()). 0 <= buffer_used_ <= buffer_size_.
240
+ int buffer_used_;
241
+
242
+ // Number of bytes in the buffer which were backed up over by a call to
243
+ // BackUp(). These need to be returned again.
244
+ // 0 <= backup_bytes_ <= buffer_used_
245
+ int backup_bytes_;
246
+
247
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingInputStreamAdaptor);
248
+ };
249
+
250
+ // ===================================================================
251
+
252
+ // A generic traditional output stream interface.
253
+ //
254
+ // Lots of traditional output streams (e.g. file descriptors, C stdio
255
+ // streams, and C++ iostreams) expose an interface where every write
256
+ // involves copying bytes from a buffer. If you want to take such an
257
+ // interface and make a ZeroCopyOutputStream based on it, simply implement
258
+ // CopyingOutputStream and then use CopyingOutputStreamAdaptor.
259
+ //
260
+ // CopyingOutputStream implementations should avoid buffering if possible.
261
+ // CopyingOutputStreamAdaptor does its own buffering and will write data
262
+ // in large blocks.
263
+ class LIBPROTOBUF_EXPORT CopyingOutputStream {
264
+ public:
265
+ virtual ~CopyingOutputStream();
266
+
267
+ // Writes "size" bytes from the given buffer to the output. Returns true
268
+ // if successful, false on a write error.
269
+ virtual bool Write(const void* buffer, int size) = 0;
270
+ };
271
+
272
+ // A ZeroCopyOutputStream which writes to a CopyingOutputStream. This is
273
+ // useful for implementing ZeroCopyOutputStreams that write to traditional
274
+ // streams. Note that this class is not really zero-copy.
275
+ //
276
+ // If you want to write to file descriptors or C++ ostreams, this is
277
+ // already implemented for you: use FileOutputStream or OstreamOutputStream
278
+ // respectively.
279
+ class LIBPROTOBUF_EXPORT CopyingOutputStreamAdaptor : public ZeroCopyOutputStream {
280
+ public:
281
+ // Creates a stream that writes to the given Unix file descriptor.
282
+ // If a block_size is given, it specifies the size of the buffers
283
+ // that should be returned by Next(). Otherwise, a reasonable default
284
+ // is used.
285
+ explicit CopyingOutputStreamAdaptor(CopyingOutputStream* copying_stream,
286
+ int block_size = -1);
287
+ ~CopyingOutputStreamAdaptor();
288
+
289
+ // Writes all pending data to the underlying stream. Returns false if a
290
+ // write error occurred on the underlying stream. (The underlying
291
+ // stream itself is not necessarily flushed.)
292
+ bool Flush();
293
+
294
+ // Call SetOwnsCopyingStream(true) to tell the CopyingOutputStreamAdaptor to
295
+ // delete the underlying CopyingOutputStream when it is destroyed.
296
+ void SetOwnsCopyingStream(bool value) { owns_copying_stream_ = value; }
297
+
298
+ // implements ZeroCopyOutputStream ---------------------------------
299
+ bool Next(void** data, int* size);
300
+ void BackUp(int count);
301
+ int64 ByteCount() const;
302
+
303
+ private:
304
+ // Write the current buffer, if it is present.
305
+ bool WriteBuffer();
306
+ // Insures that buffer_ is not NULL.
307
+ void AllocateBufferIfNeeded();
308
+ // Frees the buffer.
309
+ void FreeBuffer();
310
+
311
+ // The underlying copying stream.
312
+ CopyingOutputStream* copying_stream_;
313
+ bool owns_copying_stream_;
314
+
315
+ // True if we have seen a permenant error from the underlying stream.
316
+ bool failed_;
317
+
318
+ // The current position of copying_stream_, relative to the point where
319
+ // we started writing.
320
+ int64 position_;
321
+
322
+ // Data is written from this buffer. It may be NULL if no buffer is
323
+ // currently in use. Otherwise, it points to an array of size buffer_size_.
324
+ scoped_array<uint8> buffer_;
325
+ const int buffer_size_;
326
+
327
+ // Number of valid bytes currently in the buffer (i.e. the size last
328
+ // returned by Next()). When BackUp() is called, we just reduce this.
329
+ // 0 <= buffer_used_ <= buffer_size_.
330
+ int buffer_used_;
331
+
332
+ GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingOutputStreamAdaptor);
333
+ };
334
+
335
+ // ===================================================================
336
+
337
+ // Return a pointer to mutable characters underlying the given string. The
338
+ // return value is valid until the next time the string is resized. We
339
+ // trust the caller to treat the return value as an array of length s->size().
340
+ inline char* mutable_string_data(string* s) {
341
+ #ifdef LANG_CXX11
342
+ // This should be simpler & faster than string_as_array() because the latter
343
+ // is guaranteed to return NULL when *s is empty, so it has to check for that.
344
+ return &(*s)[0];
345
+ #else
346
+ return string_as_array(s);
347
+ #endif
348
+ }
349
+
350
+ } // namespace io
351
+ } // namespace protobuf
352
+
353
+ } // namespace google
354
+ #endif // GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_LITE_H__
@@ -0,0 +1,965 @@
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
+ // Testing strategy: For each type of I/O (array, string, file, etc.) we
36
+ // create an output stream and write some data to it, then create a
37
+ // corresponding input stream to read the same data back and expect it to
38
+ // match. When the data is written, it is written in several small chunks
39
+ // of varying sizes, with a BackUp() after each chunk. It is read back
40
+ // similarly, but with chunks separated at different points. The whole
41
+ // process is run with a variety of block sizes for both the input and
42
+ // the output.
43
+ //
44
+ // TODO(kenton): Rewrite this test to bring it up to the standards of all
45
+ // the other proto2 tests. May want to wait for gTest to implement
46
+ // "parametized tests" so that one set of tests can be used on all the
47
+ // implementations.
48
+
49
+ #include "config.h"
50
+
51
+ #ifdef _MSC_VER
52
+ #include <io.h>
53
+ #else
54
+ #include <unistd.h>
55
+ #endif
56
+ #include <stdlib.h>
57
+ #include <sys/types.h>
58
+ #include <sys/stat.h>
59
+ #include <fcntl.h>
60
+ #include <errno.h>
61
+ #include <sstream>
62
+
63
+ #include <google/protobuf/io/zero_copy_stream_impl.h>
64
+ #include <google/protobuf/io/coded_stream.h>
65
+
66
+ #if HAVE_ZLIB
67
+ #include <google/protobuf/io/gzip_stream.h>
68
+ #endif
69
+
70
+ #include <google/protobuf/stubs/common.h>
71
+ #include <google/protobuf/testing/googletest.h>
72
+ #include <google/protobuf/testing/file.h>
73
+ #include <gtest/gtest.h>
74
+
75
+ namespace google {
76
+ namespace protobuf {
77
+ namespace io {
78
+ namespace {
79
+
80
+ #ifdef _WIN32
81
+ #define pipe(fds) _pipe(fds, 4096, O_BINARY)
82
+ #endif
83
+
84
+ #ifndef O_BINARY
85
+ #ifdef _O_BINARY
86
+ #define O_BINARY _O_BINARY
87
+ #else
88
+ #define O_BINARY 0 // If this isn't defined, the platform doesn't need it.
89
+ #endif
90
+ #endif
91
+
92
+ class IoTest : public testing::Test {
93
+ protected:
94
+ // Test helpers.
95
+
96
+ // Helper to write an array of data to an output stream.
97
+ bool WriteToOutput(ZeroCopyOutputStream* output, const void* data, int size);
98
+ // Helper to read a fixed-length array of data from an input stream.
99
+ int ReadFromInput(ZeroCopyInputStream* input, void* data, int size);
100
+ // Write a string to the output stream.
101
+ void WriteString(ZeroCopyOutputStream* output, const string& str);
102
+ // Read a number of bytes equal to the size of the given string and checks
103
+ // that it matches the string.
104
+ void ReadString(ZeroCopyInputStream* input, const string& str);
105
+ // Writes some text to the output stream in a particular order. Returns
106
+ // the number of bytes written, incase the caller needs that to set up an
107
+ // input stream.
108
+ int WriteStuff(ZeroCopyOutputStream* output);
109
+ // Reads text from an input stream and expects it to match what
110
+ // WriteStuff() writes.
111
+ void ReadStuff(ZeroCopyInputStream* input);
112
+
113
+ // Similar to WriteStuff, but performs more sophisticated testing.
114
+ int WriteStuffLarge(ZeroCopyOutputStream* output);
115
+ // Reads and tests a stream that should have been written to
116
+ // via WriteStuffLarge().
117
+ void ReadStuffLarge(ZeroCopyInputStream* input);
118
+
119
+ #if HAVE_ZLIB
120
+ string Compress(const string& data, const GzipOutputStream::Options& options);
121
+ string Uncompress(const string& data);
122
+ #endif
123
+
124
+ static const int kBlockSizes[];
125
+ static const int kBlockSizeCount;
126
+ };
127
+
128
+ const int IoTest::kBlockSizes[] = {-1, 1, 2, 5, 7, 10, 23, 64};
129
+ const int IoTest::kBlockSizeCount = GOOGLE_ARRAYSIZE(IoTest::kBlockSizes);
130
+
131
+ bool IoTest::WriteToOutput(ZeroCopyOutputStream* output,
132
+ const void* data, int size) {
133
+ const uint8* in = reinterpret_cast<const uint8*>(data);
134
+ int in_size = size;
135
+
136
+ void* out;
137
+ int out_size;
138
+
139
+ while (true) {
140
+ if (!output->Next(&out, &out_size)) {
141
+ return false;
142
+ }
143
+ EXPECT_GT(out_size, 0);
144
+
145
+ if (in_size <= out_size) {
146
+ memcpy(out, in, in_size);
147
+ output->BackUp(out_size - in_size);
148
+ return true;
149
+ }
150
+
151
+ memcpy(out, in, out_size);
152
+ in += out_size;
153
+ in_size -= out_size;
154
+ }
155
+ }
156
+
157
+ #define MAX_REPEATED_ZEROS 100
158
+
159
+ int IoTest::ReadFromInput(ZeroCopyInputStream* input, void* data, int size) {
160
+ uint8* out = reinterpret_cast<uint8*>(data);
161
+ int out_size = size;
162
+
163
+ const void* in;
164
+ int in_size = 0;
165
+
166
+ int repeated_zeros = 0;
167
+
168
+ while (true) {
169
+ if (!input->Next(&in, &in_size)) {
170
+ return size - out_size;
171
+ }
172
+ EXPECT_GT(in_size, -1);
173
+ if (in_size == 0) {
174
+ repeated_zeros++;
175
+ } else {
176
+ repeated_zeros = 0;
177
+ }
178
+ EXPECT_LT(repeated_zeros, MAX_REPEATED_ZEROS);
179
+
180
+ if (out_size <= in_size) {
181
+ memcpy(out, in, out_size);
182
+ if (in_size > out_size) {
183
+ input->BackUp(in_size - out_size);
184
+ }
185
+ return size; // Copied all of it.
186
+ }
187
+
188
+ memcpy(out, in, in_size);
189
+ out += in_size;
190
+ out_size -= in_size;
191
+ }
192
+ }
193
+
194
+ void IoTest::WriteString(ZeroCopyOutputStream* output, const string& str) {
195
+ EXPECT_TRUE(WriteToOutput(output, str.c_str(), str.size()));
196
+ }
197
+
198
+ void IoTest::ReadString(ZeroCopyInputStream* input, const string& str) {
199
+ scoped_array<char> buffer(new char[str.size() + 1]);
200
+ buffer[str.size()] = '\0';
201
+ EXPECT_EQ(ReadFromInput(input, buffer.get(), str.size()), str.size());
202
+ EXPECT_STREQ(str.c_str(), buffer.get());
203
+ }
204
+
205
+ int IoTest::WriteStuff(ZeroCopyOutputStream* output) {
206
+ WriteString(output, "Hello world!\n");
207
+ WriteString(output, "Some te");
208
+ WriteString(output, "xt. Blah blah.");
209
+ WriteString(output, "abcdefg");
210
+ WriteString(output, "01234567890123456789");
211
+ WriteString(output, "foobar");
212
+
213
+ EXPECT_EQ(output->ByteCount(), 68);
214
+
215
+ int result = output->ByteCount();
216
+ return result;
217
+ }
218
+
219
+ // Reads text from an input stream and expects it to match what WriteStuff()
220
+ // writes.
221
+ void IoTest::ReadStuff(ZeroCopyInputStream* input) {
222
+ ReadString(input, "Hello world!\n");
223
+ ReadString(input, "Some text. ");
224
+ ReadString(input, "Blah ");
225
+ ReadString(input, "blah.");
226
+ ReadString(input, "abcdefg");
227
+ EXPECT_TRUE(input->Skip(20));
228
+ ReadString(input, "foo");
229
+ ReadString(input, "bar");
230
+
231
+ EXPECT_EQ(input->ByteCount(), 68);
232
+
233
+ uint8 byte;
234
+ EXPECT_EQ(ReadFromInput(input, &byte, 1), 0);
235
+ }
236
+
237
+ int IoTest::WriteStuffLarge(ZeroCopyOutputStream* output) {
238
+ WriteString(output, "Hello world!\n");
239
+ WriteString(output, "Some te");
240
+ WriteString(output, "xt. Blah blah.");
241
+ WriteString(output, string(100000, 'x')); // A very long string
242
+ WriteString(output, string(100000, 'y')); // A very long string
243
+ WriteString(output, "01234567890123456789");
244
+
245
+ EXPECT_EQ(output->ByteCount(), 200055);
246
+
247
+ int result = output->ByteCount();
248
+ return result;
249
+ }
250
+
251
+ // Reads text from an input stream and expects it to match what WriteStuff()
252
+ // writes.
253
+ void IoTest::ReadStuffLarge(ZeroCopyInputStream* input) {
254
+ ReadString(input, "Hello world!\nSome text. ");
255
+ EXPECT_TRUE(input->Skip(5));
256
+ ReadString(input, "blah.");
257
+ EXPECT_TRUE(input->Skip(100000 - 10));
258
+ ReadString(input, string(10, 'x') + string(100000 - 20000, 'y'));
259
+ EXPECT_TRUE(input->Skip(20000 - 10));
260
+ ReadString(input, "yyyyyyyyyy01234567890123456789");
261
+
262
+ EXPECT_EQ(input->ByteCount(), 200055);
263
+
264
+ uint8 byte;
265
+ EXPECT_EQ(ReadFromInput(input, &byte, 1), 0);
266
+ }
267
+
268
+ // ===================================================================
269
+
270
+ TEST_F(IoTest, ArrayIo) {
271
+ const int kBufferSize = 256;
272
+ uint8 buffer[kBufferSize];
273
+
274
+ for (int i = 0; i < kBlockSizeCount; i++) {
275
+ for (int j = 0; j < kBlockSizeCount; j++) {
276
+ int size;
277
+ {
278
+ ArrayOutputStream output(buffer, kBufferSize, kBlockSizes[i]);
279
+ size = WriteStuff(&output);
280
+ }
281
+ {
282
+ ArrayInputStream input(buffer, size, kBlockSizes[j]);
283
+ ReadStuff(&input);
284
+ }
285
+ }
286
+ }
287
+ }
288
+
289
+ TEST_F(IoTest, TwoSessionWrite) {
290
+ // Test that two concatenated write sessions read correctly
291
+
292
+ static const char* strA = "0123456789";
293
+ static const char* strB = "WhirledPeas";
294
+ const int kBufferSize = 2*1024;
295
+ uint8* buffer = new uint8[kBufferSize];
296
+ char* temp_buffer = new char[40];
297
+
298
+ for (int i = 0; i < kBlockSizeCount; i++) {
299
+ for (int j = 0; j < kBlockSizeCount; j++) {
300
+ ArrayOutputStream* output =
301
+ new ArrayOutputStream(buffer, kBufferSize, kBlockSizes[i]);
302
+ CodedOutputStream* coded_output = new CodedOutputStream(output);
303
+ coded_output->WriteVarint32(strlen(strA));
304
+ coded_output->WriteRaw(strA, strlen(strA));
305
+ delete coded_output; // flush
306
+ int64 pos = output->ByteCount();
307
+ delete output;
308
+ output = new ArrayOutputStream(
309
+ buffer + pos, kBufferSize - pos, kBlockSizes[i]);
310
+ coded_output = new CodedOutputStream(output);
311
+ coded_output->WriteVarint32(strlen(strB));
312
+ coded_output->WriteRaw(strB, strlen(strB));
313
+ delete coded_output; // flush
314
+ int64 size = pos + output->ByteCount();
315
+ delete output;
316
+
317
+ ArrayInputStream* input =
318
+ new ArrayInputStream(buffer, size, kBlockSizes[j]);
319
+ CodedInputStream* coded_input = new CodedInputStream(input);
320
+ uint32 insize;
321
+ EXPECT_TRUE(coded_input->ReadVarint32(&insize));
322
+ EXPECT_EQ(strlen(strA), insize);
323
+ EXPECT_TRUE(coded_input->ReadRaw(temp_buffer, insize));
324
+ EXPECT_EQ(0, memcmp(temp_buffer, strA, insize));
325
+
326
+ EXPECT_TRUE(coded_input->ReadVarint32(&insize));
327
+ EXPECT_EQ(strlen(strB), insize);
328
+ EXPECT_TRUE(coded_input->ReadRaw(temp_buffer, insize));
329
+ EXPECT_EQ(0, memcmp(temp_buffer, strB, insize));
330
+
331
+ delete coded_input;
332
+ delete input;
333
+ }
334
+ }
335
+
336
+ delete [] temp_buffer;
337
+ delete [] buffer;
338
+ }
339
+
340
+ #if HAVE_ZLIB
341
+ TEST_F(IoTest, GzipIo) {
342
+ const int kBufferSize = 2*1024;
343
+ uint8* buffer = new uint8[kBufferSize];
344
+ for (int i = 0; i < kBlockSizeCount; i++) {
345
+ for (int j = 0; j < kBlockSizeCount; j++) {
346
+ for (int z = 0; z < kBlockSizeCount; z++) {
347
+ int gzip_buffer_size = kBlockSizes[z];
348
+ int size;
349
+ {
350
+ ArrayOutputStream output(buffer, kBufferSize, kBlockSizes[i]);
351
+ GzipOutputStream::Options options;
352
+ options.format = GzipOutputStream::GZIP;
353
+ if (gzip_buffer_size != -1) {
354
+ options.buffer_size = gzip_buffer_size;
355
+ }
356
+ GzipOutputStream gzout(&output, options);
357
+ WriteStuff(&gzout);
358
+ gzout.Close();
359
+ size = output.ByteCount();
360
+ }
361
+ {
362
+ ArrayInputStream input(buffer, size, kBlockSizes[j]);
363
+ GzipInputStream gzin(
364
+ &input, GzipInputStream::GZIP, gzip_buffer_size);
365
+ ReadStuff(&gzin);
366
+ }
367
+ }
368
+ }
369
+ }
370
+ delete [] buffer;
371
+ }
372
+
373
+ TEST_F(IoTest, GzipIoWithFlush) {
374
+ const int kBufferSize = 2*1024;
375
+ uint8* buffer = new uint8[kBufferSize];
376
+ // We start with i = 4 as we want a block size > 6. With block size <= 6
377
+ // Flush() fills up the entire 2K buffer with flush markers and the test
378
+ // fails. See documentation for Flush() for more detail.
379
+ for (int i = 4; i < kBlockSizeCount; i++) {
380
+ for (int j = 0; j < kBlockSizeCount; j++) {
381
+ for (int z = 0; z < kBlockSizeCount; z++) {
382
+ int gzip_buffer_size = kBlockSizes[z];
383
+ int size;
384
+ {
385
+ ArrayOutputStream output(buffer, kBufferSize, kBlockSizes[i]);
386
+ GzipOutputStream::Options options;
387
+ options.format = GzipOutputStream::GZIP;
388
+ if (gzip_buffer_size != -1) {
389
+ options.buffer_size = gzip_buffer_size;
390
+ }
391
+ GzipOutputStream gzout(&output, options);
392
+ WriteStuff(&gzout);
393
+ EXPECT_TRUE(gzout.Flush());
394
+ gzout.Close();
395
+ size = output.ByteCount();
396
+ }
397
+ {
398
+ ArrayInputStream input(buffer, size, kBlockSizes[j]);
399
+ GzipInputStream gzin(
400
+ &input, GzipInputStream::GZIP, gzip_buffer_size);
401
+ ReadStuff(&gzin);
402
+ }
403
+ }
404
+ }
405
+ }
406
+ delete [] buffer;
407
+ }
408
+
409
+ TEST_F(IoTest, GzipIoContiguousFlushes) {
410
+ const int kBufferSize = 2*1024;
411
+ uint8* buffer = new uint8[kBufferSize];
412
+
413
+ int block_size = kBlockSizes[4];
414
+ int gzip_buffer_size = block_size;
415
+ int size;
416
+
417
+ ArrayOutputStream output(buffer, kBufferSize, block_size);
418
+ GzipOutputStream::Options options;
419
+ options.format = GzipOutputStream::GZIP;
420
+ if (gzip_buffer_size != -1) {
421
+ options.buffer_size = gzip_buffer_size;
422
+ }
423
+ GzipOutputStream gzout(&output, options);
424
+ WriteStuff(&gzout);
425
+ EXPECT_TRUE(gzout.Flush());
426
+ EXPECT_TRUE(gzout.Flush());
427
+ gzout.Close();
428
+ size = output.ByteCount();
429
+
430
+ ArrayInputStream input(buffer, size, block_size);
431
+ GzipInputStream gzin(
432
+ &input, GzipInputStream::GZIP, gzip_buffer_size);
433
+ ReadStuff(&gzin);
434
+
435
+ delete [] buffer;
436
+ }
437
+
438
+ TEST_F(IoTest, GzipIoReadAfterFlush) {
439
+ const int kBufferSize = 2*1024;
440
+ uint8* buffer = new uint8[kBufferSize];
441
+
442
+ int block_size = kBlockSizes[4];
443
+ int gzip_buffer_size = block_size;
444
+ int size;
445
+ ArrayOutputStream output(buffer, kBufferSize, block_size);
446
+ GzipOutputStream::Options options;
447
+ options.format = GzipOutputStream::GZIP;
448
+ if (gzip_buffer_size != -1) {
449
+ options.buffer_size = gzip_buffer_size;
450
+ }
451
+
452
+ GzipOutputStream gzout(&output, options);
453
+ WriteStuff(&gzout);
454
+ EXPECT_TRUE(gzout.Flush());
455
+ size = output.ByteCount();
456
+
457
+ ArrayInputStream input(buffer, size, block_size);
458
+ GzipInputStream gzin(
459
+ &input, GzipInputStream::GZIP, gzip_buffer_size);
460
+ ReadStuff(&gzin);
461
+
462
+ gzout.Close();
463
+
464
+ delete [] buffer;
465
+ }
466
+
467
+ TEST_F(IoTest, ZlibIo) {
468
+ const int kBufferSize = 2*1024;
469
+ uint8* buffer = new uint8[kBufferSize];
470
+ for (int i = 0; i < kBlockSizeCount; i++) {
471
+ for (int j = 0; j < kBlockSizeCount; j++) {
472
+ for (int z = 0; z < kBlockSizeCount; z++) {
473
+ int gzip_buffer_size = kBlockSizes[z];
474
+ int size;
475
+ {
476
+ ArrayOutputStream output(buffer, kBufferSize, kBlockSizes[i]);
477
+ GzipOutputStream::Options options;
478
+ options.format = GzipOutputStream::ZLIB;
479
+ if (gzip_buffer_size != -1) {
480
+ options.buffer_size = gzip_buffer_size;
481
+ }
482
+ GzipOutputStream gzout(&output, options);
483
+ WriteStuff(&gzout);
484
+ gzout.Close();
485
+ size = output.ByteCount();
486
+ }
487
+ {
488
+ ArrayInputStream input(buffer, size, kBlockSizes[j]);
489
+ GzipInputStream gzin(
490
+ &input, GzipInputStream::ZLIB, gzip_buffer_size);
491
+ ReadStuff(&gzin);
492
+ }
493
+ }
494
+ }
495
+ }
496
+ delete [] buffer;
497
+ }
498
+
499
+ TEST_F(IoTest, ZlibIoInputAutodetect) {
500
+ const int kBufferSize = 2*1024;
501
+ uint8* buffer = new uint8[kBufferSize];
502
+ int size;
503
+ {
504
+ ArrayOutputStream output(buffer, kBufferSize);
505
+ GzipOutputStream::Options options;
506
+ options.format = GzipOutputStream::ZLIB;
507
+ GzipOutputStream gzout(&output, options);
508
+ WriteStuff(&gzout);
509
+ gzout.Close();
510
+ size = output.ByteCount();
511
+ }
512
+ {
513
+ ArrayInputStream input(buffer, size);
514
+ GzipInputStream gzin(&input, GzipInputStream::AUTO);
515
+ ReadStuff(&gzin);
516
+ }
517
+ {
518
+ ArrayOutputStream output(buffer, kBufferSize);
519
+ GzipOutputStream::Options options;
520
+ options.format = GzipOutputStream::GZIP;
521
+ GzipOutputStream gzout(&output, options);
522
+ WriteStuff(&gzout);
523
+ gzout.Close();
524
+ size = output.ByteCount();
525
+ }
526
+ {
527
+ ArrayInputStream input(buffer, size);
528
+ GzipInputStream gzin(&input, GzipInputStream::AUTO);
529
+ ReadStuff(&gzin);
530
+ }
531
+ delete [] buffer;
532
+ }
533
+
534
+ string IoTest::Compress(const string& data,
535
+ const GzipOutputStream::Options& options) {
536
+ string result;
537
+ {
538
+ StringOutputStream output(&result);
539
+ GzipOutputStream gzout(&output, options);
540
+ WriteToOutput(&gzout, data.data(), data.size());
541
+ }
542
+ return result;
543
+ }
544
+
545
+ string IoTest::Uncompress(const string& data) {
546
+ string result;
547
+ {
548
+ ArrayInputStream input(data.data(), data.size());
549
+ GzipInputStream gzin(&input);
550
+ const void* buffer;
551
+ int size;
552
+ while (gzin.Next(&buffer, &size)) {
553
+ result.append(reinterpret_cast<const char*>(buffer), size);
554
+ }
555
+ }
556
+ return result;
557
+ }
558
+
559
+ TEST_F(IoTest, CompressionOptions) {
560
+ // Some ad-hoc testing of compression options.
561
+
562
+ string golden;
563
+ GOOGLE_CHECK_OK(File::GetContents(
564
+ TestSourceDir() +
565
+ "/google/protobuf/testdata/golden_message",
566
+ &golden, true));
567
+
568
+ GzipOutputStream::Options options;
569
+ string gzip_compressed = Compress(golden, options);
570
+
571
+ options.compression_level = 0;
572
+ string not_compressed = Compress(golden, options);
573
+
574
+ // Try zlib compression for fun.
575
+ options = GzipOutputStream::Options();
576
+ options.format = GzipOutputStream::ZLIB;
577
+ string zlib_compressed = Compress(golden, options);
578
+
579
+ // Uncompressed should be bigger than the original since it should have some
580
+ // sort of header.
581
+ EXPECT_GT(not_compressed.size(), golden.size());
582
+
583
+ // Higher compression levels should result in smaller sizes.
584
+ EXPECT_LT(zlib_compressed.size(), not_compressed.size());
585
+
586
+ // ZLIB format should differ from GZIP format.
587
+ EXPECT_TRUE(zlib_compressed != gzip_compressed);
588
+
589
+ // Everything should decompress correctly.
590
+ EXPECT_TRUE(Uncompress(not_compressed) == golden);
591
+ EXPECT_TRUE(Uncompress(gzip_compressed) == golden);
592
+ EXPECT_TRUE(Uncompress(zlib_compressed) == golden);
593
+ }
594
+
595
+ TEST_F(IoTest, TwoSessionWriteGzip) {
596
+ // Test that two concatenated gzip streams can be read correctly
597
+
598
+ static const char* strA = "0123456789";
599
+ static const char* strB = "QuickBrownFox";
600
+ const int kBufferSize = 2*1024;
601
+ uint8* buffer = new uint8[kBufferSize];
602
+ char* temp_buffer = new char[40];
603
+
604
+ for (int i = 0; i < kBlockSizeCount; i++) {
605
+ for (int j = 0; j < kBlockSizeCount; j++) {
606
+ ArrayOutputStream* output =
607
+ new ArrayOutputStream(buffer, kBufferSize, kBlockSizes[i]);
608
+ GzipOutputStream* gzout = new GzipOutputStream(output);
609
+ CodedOutputStream* coded_output = new CodedOutputStream(gzout);
610
+ int32 outlen = strlen(strA) + 1;
611
+ coded_output->WriteVarint32(outlen);
612
+ coded_output->WriteRaw(strA, outlen);
613
+ delete coded_output; // flush
614
+ delete gzout; // flush
615
+ int64 pos = output->ByteCount();
616
+ delete output;
617
+ output = new ArrayOutputStream(
618
+ buffer + pos, kBufferSize - pos, kBlockSizes[i]);
619
+ gzout = new GzipOutputStream(output);
620
+ coded_output = new CodedOutputStream(gzout);
621
+ outlen = strlen(strB) + 1;
622
+ coded_output->WriteVarint32(outlen);
623
+ coded_output->WriteRaw(strB, outlen);
624
+ delete coded_output; // flush
625
+ delete gzout; // flush
626
+ int64 size = pos + output->ByteCount();
627
+ delete output;
628
+
629
+ ArrayInputStream* input =
630
+ new ArrayInputStream(buffer, size, kBlockSizes[j]);
631
+ GzipInputStream* gzin = new GzipInputStream(input);
632
+ CodedInputStream* coded_input = new CodedInputStream(gzin);
633
+ uint32 insize;
634
+ EXPECT_TRUE(coded_input->ReadVarint32(&insize));
635
+ EXPECT_EQ(strlen(strA) + 1, insize);
636
+ EXPECT_TRUE(coded_input->ReadRaw(temp_buffer, insize));
637
+ EXPECT_EQ(0, memcmp(temp_buffer, strA, insize))
638
+ << "strA=" << strA << " in=" << temp_buffer;
639
+
640
+ EXPECT_TRUE(coded_input->ReadVarint32(&insize));
641
+ EXPECT_EQ(strlen(strB) + 1, insize);
642
+ EXPECT_TRUE(coded_input->ReadRaw(temp_buffer, insize));
643
+ EXPECT_EQ(0, memcmp(temp_buffer, strB, insize))
644
+ << " out_block_size=" << kBlockSizes[i]
645
+ << " in_block_size=" << kBlockSizes[j]
646
+ << " pos=" << pos
647
+ << " size=" << size
648
+ << " strB=" << strB << " in=" << temp_buffer;
649
+
650
+ delete coded_input;
651
+ delete gzin;
652
+ delete input;
653
+ }
654
+ }
655
+
656
+ delete [] temp_buffer;
657
+ delete [] buffer;
658
+ }
659
+ #endif
660
+
661
+ // There is no string input, only string output. Also, it doesn't support
662
+ // explicit block sizes. So, we'll only run one test and we'll use
663
+ // ArrayInput to read back the results.
664
+ TEST_F(IoTest, StringIo) {
665
+ string str;
666
+ {
667
+ StringOutputStream output(&str);
668
+ WriteStuff(&output);
669
+ }
670
+ {
671
+ ArrayInputStream input(str.data(), str.size());
672
+ ReadStuff(&input);
673
+ }
674
+ }
675
+
676
+
677
+ // To test files, we create a temporary file, write, read, truncate, repeat.
678
+ TEST_F(IoTest, FileIo) {
679
+ string filename = TestTempDir() + "/zero_copy_stream_test_file";
680
+
681
+ for (int i = 0; i < kBlockSizeCount; i++) {
682
+ for (int j = 0; j < kBlockSizeCount; j++) {
683
+ // Make a temporary file.
684
+ int file =
685
+ open(filename.c_str(), O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0777);
686
+ ASSERT_GE(file, 0);
687
+
688
+ {
689
+ FileOutputStream output(file, kBlockSizes[i]);
690
+ WriteStuff(&output);
691
+ EXPECT_EQ(0, output.GetErrno());
692
+ }
693
+
694
+ // Rewind.
695
+ ASSERT_NE(lseek(file, 0, SEEK_SET), (off_t)-1);
696
+
697
+ {
698
+ FileInputStream input(file, kBlockSizes[j]);
699
+ ReadStuff(&input);
700
+ EXPECT_EQ(0, input.GetErrno());
701
+ }
702
+
703
+ close(file);
704
+ }
705
+ }
706
+ }
707
+
708
+ #if HAVE_ZLIB
709
+ TEST_F(IoTest, GzipFileIo) {
710
+ string filename = TestTempDir() + "/zero_copy_stream_test_file";
711
+
712
+ for (int i = 0; i < kBlockSizeCount; i++) {
713
+ for (int j = 0; j < kBlockSizeCount; j++) {
714
+ // Make a temporary file.
715
+ int file =
716
+ open(filename.c_str(), O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0777);
717
+ ASSERT_GE(file, 0);
718
+ {
719
+ FileOutputStream output(file, kBlockSizes[i]);
720
+ GzipOutputStream gzout(&output);
721
+ WriteStuffLarge(&gzout);
722
+ gzout.Close();
723
+ output.Flush();
724
+ EXPECT_EQ(0, output.GetErrno());
725
+ }
726
+
727
+ // Rewind.
728
+ ASSERT_NE(lseek(file, 0, SEEK_SET), (off_t)-1);
729
+
730
+ {
731
+ FileInputStream input(file, kBlockSizes[j]);
732
+ GzipInputStream gzin(&input);
733
+ ReadStuffLarge(&gzin);
734
+ EXPECT_EQ(0, input.GetErrno());
735
+ }
736
+
737
+ close(file);
738
+ }
739
+ }
740
+ }
741
+ #endif
742
+
743
+ // MSVC raises various debugging exceptions if we try to use a file
744
+ // descriptor of -1, defeating our tests below. This class will disable
745
+ // these debug assertions while in scope.
746
+ class MsvcDebugDisabler {
747
+ public:
748
+ #if defined(_MSC_VER) && _MSC_VER >= 1400
749
+ MsvcDebugDisabler() {
750
+ old_handler_ = _set_invalid_parameter_handler(MyHandler);
751
+ old_mode_ = _CrtSetReportMode(_CRT_ASSERT, 0);
752
+ }
753
+ ~MsvcDebugDisabler() {
754
+ old_handler_ = _set_invalid_parameter_handler(old_handler_);
755
+ old_mode_ = _CrtSetReportMode(_CRT_ASSERT, old_mode_);
756
+ }
757
+
758
+ static void MyHandler(const wchar_t *expr,
759
+ const wchar_t *func,
760
+ const wchar_t *file,
761
+ unsigned int line,
762
+ uintptr_t pReserved) {
763
+ // do nothing
764
+ }
765
+
766
+ _invalid_parameter_handler old_handler_;
767
+ int old_mode_;
768
+ #else
769
+ // Dummy constructor and destructor to ensure that GCC doesn't complain
770
+ // that debug_disabler is an unused variable.
771
+ MsvcDebugDisabler() {}
772
+ ~MsvcDebugDisabler() {}
773
+ #endif
774
+ };
775
+
776
+ // Test that FileInputStreams report errors correctly.
777
+ TEST_F(IoTest, FileReadError) {
778
+ MsvcDebugDisabler debug_disabler;
779
+
780
+ // -1 = invalid file descriptor.
781
+ FileInputStream input(-1);
782
+
783
+ const void* buffer;
784
+ int size;
785
+ EXPECT_FALSE(input.Next(&buffer, &size));
786
+ EXPECT_EQ(EBADF, input.GetErrno());
787
+ }
788
+
789
+ // Test that FileOutputStreams report errors correctly.
790
+ TEST_F(IoTest, FileWriteError) {
791
+ MsvcDebugDisabler debug_disabler;
792
+
793
+ // -1 = invalid file descriptor.
794
+ FileOutputStream input(-1);
795
+
796
+ void* buffer;
797
+ int size;
798
+
799
+ // The first call to Next() succeeds because it doesn't have anything to
800
+ // write yet.
801
+ EXPECT_TRUE(input.Next(&buffer, &size));
802
+
803
+ // Second call fails.
804
+ EXPECT_FALSE(input.Next(&buffer, &size));
805
+
806
+ EXPECT_EQ(EBADF, input.GetErrno());
807
+ }
808
+
809
+ // Pipes are not seekable, so File{Input,Output}Stream ends up doing some
810
+ // different things to handle them. We'll test by writing to a pipe and
811
+ // reading back from it.
812
+ TEST_F(IoTest, PipeIo) {
813
+ int files[2];
814
+
815
+ for (int i = 0; i < kBlockSizeCount; i++) {
816
+ for (int j = 0; j < kBlockSizeCount; j++) {
817
+ // Need to create a new pipe each time because ReadStuff() expects
818
+ // to see EOF at the end.
819
+ ASSERT_EQ(pipe(files), 0);
820
+
821
+ {
822
+ FileOutputStream output(files[1], kBlockSizes[i]);
823
+ WriteStuff(&output);
824
+ EXPECT_EQ(0, output.GetErrno());
825
+ }
826
+ close(files[1]); // Send EOF.
827
+
828
+ {
829
+ FileInputStream input(files[0], kBlockSizes[j]);
830
+ ReadStuff(&input);
831
+ EXPECT_EQ(0, input.GetErrno());
832
+ }
833
+ close(files[0]);
834
+ }
835
+ }
836
+ }
837
+
838
+ // Test using C++ iostreams.
839
+ TEST_F(IoTest, IostreamIo) {
840
+ for (int i = 0; i < kBlockSizeCount; i++) {
841
+ for (int j = 0; j < kBlockSizeCount; j++) {
842
+ {
843
+ stringstream stream;
844
+
845
+ {
846
+ OstreamOutputStream output(&stream, kBlockSizes[i]);
847
+ WriteStuff(&output);
848
+ EXPECT_FALSE(stream.fail());
849
+ }
850
+
851
+ {
852
+ IstreamInputStream input(&stream, kBlockSizes[j]);
853
+ ReadStuff(&input);
854
+ EXPECT_TRUE(stream.eof());
855
+ }
856
+ }
857
+
858
+ {
859
+ stringstream stream;
860
+
861
+ {
862
+ OstreamOutputStream output(&stream, kBlockSizes[i]);
863
+ WriteStuffLarge(&output);
864
+ EXPECT_FALSE(stream.fail());
865
+ }
866
+
867
+ {
868
+ IstreamInputStream input(&stream, kBlockSizes[j]);
869
+ ReadStuffLarge(&input);
870
+ EXPECT_TRUE(stream.eof());
871
+ }
872
+ }
873
+ }
874
+ }
875
+ }
876
+
877
+ // To test ConcatenatingInputStream, we create several ArrayInputStreams
878
+ // covering a buffer and then concatenate them.
879
+ TEST_F(IoTest, ConcatenatingInputStream) {
880
+ const int kBufferSize = 256;
881
+ uint8 buffer[kBufferSize];
882
+
883
+ // Fill the buffer.
884
+ ArrayOutputStream output(buffer, kBufferSize);
885
+ WriteStuff(&output);
886
+
887
+ // Now split it up into multiple streams of varying sizes.
888
+ ASSERT_EQ(68, output.ByteCount()); // Test depends on this.
889
+ ArrayInputStream input1(buffer , 12);
890
+ ArrayInputStream input2(buffer + 12, 7);
891
+ ArrayInputStream input3(buffer + 19, 6);
892
+ ArrayInputStream input4(buffer + 25, 15);
893
+ ArrayInputStream input5(buffer + 40, 0);
894
+ // Note: We want to make sure we have a stream boundary somewhere between
895
+ // bytes 42 and 62, which is the range that it Skip()ed by ReadStuff(). This
896
+ // tests that a bug that existed in the original code for Skip() is fixed.
897
+ ArrayInputStream input6(buffer + 40, 10);
898
+ ArrayInputStream input7(buffer + 50, 18); // Total = 68 bytes.
899
+
900
+ ZeroCopyInputStream* streams[] =
901
+ {&input1, &input2, &input3, &input4, &input5, &input6, &input7};
902
+
903
+ // Create the concatenating stream and read.
904
+ ConcatenatingInputStream input(streams, GOOGLE_ARRAYSIZE(streams));
905
+ ReadStuff(&input);
906
+ }
907
+
908
+ // To test LimitingInputStream, we write our golden text to a buffer, then
909
+ // create an ArrayInputStream that contains the whole buffer (not just the
910
+ // bytes written), then use a LimitingInputStream to limit it just to the
911
+ // bytes written.
912
+ TEST_F(IoTest, LimitingInputStream) {
913
+ const int kBufferSize = 256;
914
+ uint8 buffer[kBufferSize];
915
+
916
+ // Fill the buffer.
917
+ ArrayOutputStream output(buffer, kBufferSize);
918
+ WriteStuff(&output);
919
+
920
+ // Set up input.
921
+ ArrayInputStream array_input(buffer, kBufferSize);
922
+ LimitingInputStream input(&array_input, output.ByteCount());
923
+
924
+ ReadStuff(&input);
925
+ }
926
+
927
+ // Checks that ByteCount works correctly for LimitingInputStreams where the
928
+ // underlying stream has already been read.
929
+ TEST_F(IoTest, LimitingInputStreamByteCount) {
930
+ const int kHalfBufferSize = 128;
931
+ const int kBufferSize = kHalfBufferSize * 2;
932
+ uint8 buffer[kBufferSize];
933
+
934
+ // Set up input. Only allow half to be read at once.
935
+ ArrayInputStream array_input(buffer, kBufferSize, kHalfBufferSize);
936
+ const void* data;
937
+ int size;
938
+ EXPECT_TRUE(array_input.Next(&data, &size));
939
+ EXPECT_EQ(kHalfBufferSize, array_input.ByteCount());
940
+ // kHalfBufferSize - 1 to test limiting logic as well.
941
+ LimitingInputStream input(&array_input, kHalfBufferSize - 1);
942
+ EXPECT_EQ(0, input.ByteCount());
943
+ EXPECT_TRUE(input.Next(&data, &size));
944
+ EXPECT_EQ(kHalfBufferSize - 1 , input.ByteCount());
945
+ }
946
+
947
+ // Check that a zero-size array doesn't confuse the code.
948
+ TEST(ZeroSizeArray, Input) {
949
+ ArrayInputStream input(NULL, 0);
950
+ const void* data;
951
+ int size;
952
+ EXPECT_FALSE(input.Next(&data, &size));
953
+ }
954
+
955
+ TEST(ZeroSizeArray, Output) {
956
+ ArrayOutputStream output(NULL, 0);
957
+ void* data;
958
+ int size;
959
+ EXPECT_FALSE(output.Next(&data, &size));
960
+ }
961
+
962
+ } // namespace
963
+ } // namespace io
964
+ } // namespace protobuf
965
+ } // namespace google