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,1401 @@
1
+ #!/usr/bin/python2.4
2
+ #
3
+ # Copyright 2008 Google Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # This file is used for testing. The original is at:
18
+ # http://code.google.com/p/pymox/
19
+
20
+ """Mox, an object-mocking framework for Python.
21
+
22
+ Mox works in the record-replay-verify paradigm. When you first create
23
+ a mock object, it is in record mode. You then programmatically set
24
+ the expected behavior of the mock object (what methods are to be
25
+ called on it, with what parameters, what they should return, and in
26
+ what order).
27
+
28
+ Once you have set up the expected mock behavior, you put it in replay
29
+ mode. Now the mock responds to method calls just as you told it to.
30
+ If an unexpected method (or an expected method with unexpected
31
+ parameters) is called, then an exception will be raised.
32
+
33
+ Once you are done interacting with the mock, you need to verify that
34
+ all the expected interactions occured. (Maybe your code exited
35
+ prematurely without calling some cleanup method!) The verify phase
36
+ ensures that every expected method was called; otherwise, an exception
37
+ will be raised.
38
+
39
+ Suggested usage / workflow:
40
+
41
+ # Create Mox factory
42
+ my_mox = Mox()
43
+
44
+ # Create a mock data access object
45
+ mock_dao = my_mox.CreateMock(DAOClass)
46
+
47
+ # Set up expected behavior
48
+ mock_dao.RetrievePersonWithIdentifier('1').AndReturn(person)
49
+ mock_dao.DeletePerson(person)
50
+
51
+ # Put mocks in replay mode
52
+ my_mox.ReplayAll()
53
+
54
+ # Inject mock object and run test
55
+ controller.SetDao(mock_dao)
56
+ controller.DeletePersonById('1')
57
+
58
+ # Verify all methods were called as expected
59
+ my_mox.VerifyAll()
60
+ """
61
+
62
+ from collections import deque
63
+ import re
64
+ import types
65
+ import unittest
66
+
67
+ import stubout
68
+
69
+ class Error(AssertionError):
70
+ """Base exception for this module."""
71
+
72
+ pass
73
+
74
+
75
+ class ExpectedMethodCallsError(Error):
76
+ """Raised when Verify() is called before all expected methods have been called
77
+ """
78
+
79
+ def __init__(self, expected_methods):
80
+ """Init exception.
81
+
82
+ Args:
83
+ # expected_methods: A sequence of MockMethod objects that should have been
84
+ # called.
85
+ expected_methods: [MockMethod]
86
+
87
+ Raises:
88
+ ValueError: if expected_methods contains no methods.
89
+ """
90
+
91
+ if not expected_methods:
92
+ raise ValueError("There must be at least one expected method")
93
+ Error.__init__(self)
94
+ self._expected_methods = expected_methods
95
+
96
+ def __str__(self):
97
+ calls = "\n".join(["%3d. %s" % (i, m)
98
+ for i, m in enumerate(self._expected_methods)])
99
+ return "Verify: Expected methods never called:\n%s" % (calls,)
100
+
101
+
102
+ class UnexpectedMethodCallError(Error):
103
+ """Raised when an unexpected method is called.
104
+
105
+ This can occur if a method is called with incorrect parameters, or out of the
106
+ specified order.
107
+ """
108
+
109
+ def __init__(self, unexpected_method, expected):
110
+ """Init exception.
111
+
112
+ Args:
113
+ # unexpected_method: MockMethod that was called but was not at the head of
114
+ # the expected_method queue.
115
+ # expected: MockMethod or UnorderedGroup the method should have
116
+ # been in.
117
+ unexpected_method: MockMethod
118
+ expected: MockMethod or UnorderedGroup
119
+ """
120
+
121
+ Error.__init__(self)
122
+ self._unexpected_method = unexpected_method
123
+ self._expected = expected
124
+
125
+ def __str__(self):
126
+ return "Unexpected method call: %s. Expecting: %s" % \
127
+ (self._unexpected_method, self._expected)
128
+
129
+
130
+ class UnknownMethodCallError(Error):
131
+ """Raised if an unknown method is requested of the mock object."""
132
+
133
+ def __init__(self, unknown_method_name):
134
+ """Init exception.
135
+
136
+ Args:
137
+ # unknown_method_name: Method call that is not part of the mocked class's
138
+ # public interface.
139
+ unknown_method_name: str
140
+ """
141
+
142
+ Error.__init__(self)
143
+ self._unknown_method_name = unknown_method_name
144
+
145
+ def __str__(self):
146
+ return "Method called is not a member of the object: %s" % \
147
+ self._unknown_method_name
148
+
149
+
150
+ class Mox(object):
151
+ """Mox: a factory for creating mock objects."""
152
+
153
+ # A list of types that should be stubbed out with MockObjects (as
154
+ # opposed to MockAnythings).
155
+ _USE_MOCK_OBJECT = [types.ClassType, types.InstanceType, types.ModuleType,
156
+ types.ObjectType, types.TypeType]
157
+
158
+ def __init__(self):
159
+ """Initialize a new Mox."""
160
+
161
+ self._mock_objects = []
162
+ self.stubs = stubout.StubOutForTesting()
163
+
164
+ def CreateMock(self, class_to_mock):
165
+ """Create a new mock object.
166
+
167
+ Args:
168
+ # class_to_mock: the class to be mocked
169
+ class_to_mock: class
170
+
171
+ Returns:
172
+ MockObject that can be used as the class_to_mock would be.
173
+ """
174
+
175
+ new_mock = MockObject(class_to_mock)
176
+ self._mock_objects.append(new_mock)
177
+ return new_mock
178
+
179
+ def CreateMockAnything(self):
180
+ """Create a mock that will accept any method calls.
181
+
182
+ This does not enforce an interface.
183
+ """
184
+
185
+ new_mock = MockAnything()
186
+ self._mock_objects.append(new_mock)
187
+ return new_mock
188
+
189
+ def ReplayAll(self):
190
+ """Set all mock objects to replay mode."""
191
+
192
+ for mock_obj in self._mock_objects:
193
+ mock_obj._Replay()
194
+
195
+
196
+ def VerifyAll(self):
197
+ """Call verify on all mock objects created."""
198
+
199
+ for mock_obj in self._mock_objects:
200
+ mock_obj._Verify()
201
+
202
+ def ResetAll(self):
203
+ """Call reset on all mock objects. This does not unset stubs."""
204
+
205
+ for mock_obj in self._mock_objects:
206
+ mock_obj._Reset()
207
+
208
+ def StubOutWithMock(self, obj, attr_name, use_mock_anything=False):
209
+ """Replace a method, attribute, etc. with a Mock.
210
+
211
+ This will replace a class or module with a MockObject, and everything else
212
+ (method, function, etc) with a MockAnything. This can be overridden to
213
+ always use a MockAnything by setting use_mock_anything to True.
214
+
215
+ Args:
216
+ obj: A Python object (class, module, instance, callable).
217
+ attr_name: str. The name of the attribute to replace with a mock.
218
+ use_mock_anything: bool. True if a MockAnything should be used regardless
219
+ of the type of attribute.
220
+ """
221
+
222
+ attr_to_replace = getattr(obj, attr_name)
223
+ if type(attr_to_replace) in self._USE_MOCK_OBJECT and not use_mock_anything:
224
+ stub = self.CreateMock(attr_to_replace)
225
+ else:
226
+ stub = self.CreateMockAnything()
227
+
228
+ self.stubs.Set(obj, attr_name, stub)
229
+
230
+ def UnsetStubs(self):
231
+ """Restore stubs to their original state."""
232
+
233
+ self.stubs.UnsetAll()
234
+
235
+ def Replay(*args):
236
+ """Put mocks into Replay mode.
237
+
238
+ Args:
239
+ # args is any number of mocks to put into replay mode.
240
+ """
241
+
242
+ for mock in args:
243
+ mock._Replay()
244
+
245
+
246
+ def Verify(*args):
247
+ """Verify mocks.
248
+
249
+ Args:
250
+ # args is any number of mocks to be verified.
251
+ """
252
+
253
+ for mock in args:
254
+ mock._Verify()
255
+
256
+
257
+ def Reset(*args):
258
+ """Reset mocks.
259
+
260
+ Args:
261
+ # args is any number of mocks to be reset.
262
+ """
263
+
264
+ for mock in args:
265
+ mock._Reset()
266
+
267
+
268
+ class MockAnything:
269
+ """A mock that can be used to mock anything.
270
+
271
+ This is helpful for mocking classes that do not provide a public interface.
272
+ """
273
+
274
+ def __init__(self):
275
+ """ """
276
+ self._Reset()
277
+
278
+ def __getattr__(self, method_name):
279
+ """Intercept method calls on this object.
280
+
281
+ A new MockMethod is returned that is aware of the MockAnything's
282
+ state (record or replay). The call will be recorded or replayed
283
+ by the MockMethod's __call__.
284
+
285
+ Args:
286
+ # method name: the name of the method being called.
287
+ method_name: str
288
+
289
+ Returns:
290
+ A new MockMethod aware of MockAnything's state (record or replay).
291
+ """
292
+
293
+ return self._CreateMockMethod(method_name)
294
+
295
+ def _CreateMockMethod(self, method_name):
296
+ """Create a new mock method call and return it.
297
+
298
+ Args:
299
+ # method name: the name of the method being called.
300
+ method_name: str
301
+
302
+ Returns:
303
+ A new MockMethod aware of MockAnything's state (record or replay).
304
+ """
305
+
306
+ return MockMethod(method_name, self._expected_calls_queue,
307
+ self._replay_mode)
308
+
309
+ def __nonzero__(self):
310
+ """Return 1 for nonzero so the mock can be used as a conditional."""
311
+
312
+ return 1
313
+
314
+ def __eq__(self, rhs):
315
+ """Provide custom logic to compare objects."""
316
+
317
+ return (isinstance(rhs, MockAnything) and
318
+ self._replay_mode == rhs._replay_mode and
319
+ self._expected_calls_queue == rhs._expected_calls_queue)
320
+
321
+ def __ne__(self, rhs):
322
+ """Provide custom logic to compare objects."""
323
+
324
+ return not self == rhs
325
+
326
+ def _Replay(self):
327
+ """Start replaying expected method calls."""
328
+
329
+ self._replay_mode = True
330
+
331
+ def _Verify(self):
332
+ """Verify that all of the expected calls have been made.
333
+
334
+ Raises:
335
+ ExpectedMethodCallsError: if there are still more method calls in the
336
+ expected queue.
337
+ """
338
+
339
+ # If the list of expected calls is not empty, raise an exception
340
+ if self._expected_calls_queue:
341
+ # The last MultipleTimesGroup is not popped from the queue.
342
+ if (len(self._expected_calls_queue) == 1 and
343
+ isinstance(self._expected_calls_queue[0], MultipleTimesGroup) and
344
+ self._expected_calls_queue[0].IsSatisfied()):
345
+ pass
346
+ else:
347
+ raise ExpectedMethodCallsError(self._expected_calls_queue)
348
+
349
+ def _Reset(self):
350
+ """Reset the state of this mock to record mode with an empty queue."""
351
+
352
+ # Maintain a list of method calls we are expecting
353
+ self._expected_calls_queue = deque()
354
+
355
+ # Make sure we are in setup mode, not replay mode
356
+ self._replay_mode = False
357
+
358
+
359
+ class MockObject(MockAnything, object):
360
+ """A mock object that simulates the public/protected interface of a class."""
361
+
362
+ def __init__(self, class_to_mock):
363
+ """Initialize a mock object.
364
+
365
+ This determines the methods and properties of the class and stores them.
366
+
367
+ Args:
368
+ # class_to_mock: class to be mocked
369
+ class_to_mock: class
370
+ """
371
+
372
+ # This is used to hack around the mixin/inheritance of MockAnything, which
373
+ # is not a proper object (it can be anything. :-)
374
+ MockAnything.__dict__['__init__'](self)
375
+
376
+ # Get a list of all the public and special methods we should mock.
377
+ self._known_methods = set()
378
+ self._known_vars = set()
379
+ self._class_to_mock = class_to_mock
380
+ for method in dir(class_to_mock):
381
+ if callable(getattr(class_to_mock, method)):
382
+ self._known_methods.add(method)
383
+ else:
384
+ self._known_vars.add(method)
385
+
386
+ def __getattr__(self, name):
387
+ """Intercept attribute request on this object.
388
+
389
+ If the attribute is a public class variable, it will be returned and not
390
+ recorded as a call.
391
+
392
+ If the attribute is not a variable, it is handled like a method
393
+ call. The method name is checked against the set of mockable
394
+ methods, and a new MockMethod is returned that is aware of the
395
+ MockObject's state (record or replay). The call will be recorded
396
+ or replayed by the MockMethod's __call__.
397
+
398
+ Args:
399
+ # name: the name of the attribute being requested.
400
+ name: str
401
+
402
+ Returns:
403
+ Either a class variable or a new MockMethod that is aware of the state
404
+ of the mock (record or replay).
405
+
406
+ Raises:
407
+ UnknownMethodCallError if the MockObject does not mock the requested
408
+ method.
409
+ """
410
+
411
+ if name in self._known_vars:
412
+ return getattr(self._class_to_mock, name)
413
+
414
+ if name in self._known_methods:
415
+ return self._CreateMockMethod(name)
416
+
417
+ raise UnknownMethodCallError(name)
418
+
419
+ def __eq__(self, rhs):
420
+ """Provide custom logic to compare objects."""
421
+
422
+ return (isinstance(rhs, MockObject) and
423
+ self._class_to_mock == rhs._class_to_mock and
424
+ self._replay_mode == rhs._replay_mode and
425
+ self._expected_calls_queue == rhs._expected_calls_queue)
426
+
427
+ def __setitem__(self, key, value):
428
+ """Provide custom logic for mocking classes that support item assignment.
429
+
430
+ Args:
431
+ key: Key to set the value for.
432
+ value: Value to set.
433
+
434
+ Returns:
435
+ Expected return value in replay mode. A MockMethod object for the
436
+ __setitem__ method that has already been called if not in replay mode.
437
+
438
+ Raises:
439
+ TypeError if the underlying class does not support item assignment.
440
+ UnexpectedMethodCallError if the object does not expect the call to
441
+ __setitem__.
442
+
443
+ """
444
+ setitem = self._class_to_mock.__dict__.get('__setitem__', None)
445
+
446
+ # Verify the class supports item assignment.
447
+ if setitem is None:
448
+ raise TypeError('object does not support item assignment')
449
+
450
+ # If we are in replay mode then simply call the mock __setitem__ method.
451
+ if self._replay_mode:
452
+ return MockMethod('__setitem__', self._expected_calls_queue,
453
+ self._replay_mode)(key, value)
454
+
455
+
456
+ # Otherwise, create a mock method __setitem__.
457
+ return self._CreateMockMethod('__setitem__')(key, value)
458
+
459
+ def __getitem__(self, key):
460
+ """Provide custom logic for mocking classes that are subscriptable.
461
+
462
+ Args:
463
+ key: Key to return the value for.
464
+
465
+ Returns:
466
+ Expected return value in replay mode. A MockMethod object for the
467
+ __getitem__ method that has already been called if not in replay mode.
468
+
469
+ Raises:
470
+ TypeError if the underlying class is not subscriptable.
471
+ UnexpectedMethodCallError if the object does not expect the call to
472
+ __setitem__.
473
+
474
+ """
475
+ getitem = self._class_to_mock.__dict__.get('__getitem__', None)
476
+
477
+ # Verify the class supports item assignment.
478
+ if getitem is None:
479
+ raise TypeError('unsubscriptable object')
480
+
481
+ # If we are in replay mode then simply call the mock __getitem__ method.
482
+ if self._replay_mode:
483
+ return MockMethod('__getitem__', self._expected_calls_queue,
484
+ self._replay_mode)(key)
485
+
486
+
487
+ # Otherwise, create a mock method __getitem__.
488
+ return self._CreateMockMethod('__getitem__')(key)
489
+
490
+ def __call__(self, *params, **named_params):
491
+ """Provide custom logic for mocking classes that are callable."""
492
+
493
+ # Verify the class we are mocking is callable
494
+ callable = self._class_to_mock.__dict__.get('__call__', None)
495
+ if callable is None:
496
+ raise TypeError('Not callable')
497
+
498
+ # Because the call is happening directly on this object instead of a method,
499
+ # the call on the mock method is made right here
500
+ mock_method = self._CreateMockMethod('__call__')
501
+ return mock_method(*params, **named_params)
502
+
503
+ @property
504
+ def __class__(self):
505
+ """Return the class that is being mocked."""
506
+
507
+ return self._class_to_mock
508
+
509
+
510
+ class MockMethod(object):
511
+ """Callable mock method.
512
+
513
+ A MockMethod should act exactly like the method it mocks, accepting parameters
514
+ and returning a value, or throwing an exception (as specified). When this
515
+ method is called, it can optionally verify whether the called method (name and
516
+ signature) matches the expected method.
517
+ """
518
+
519
+ def __init__(self, method_name, call_queue, replay_mode):
520
+ """Construct a new mock method.
521
+
522
+ Args:
523
+ # method_name: the name of the method
524
+ # call_queue: deque of calls, verify this call against the head, or add
525
+ # this call to the queue.
526
+ # replay_mode: False if we are recording, True if we are verifying calls
527
+ # against the call queue.
528
+ method_name: str
529
+ call_queue: list or deque
530
+ replay_mode: bool
531
+ """
532
+
533
+ self._name = method_name
534
+ self._call_queue = call_queue
535
+ if not isinstance(call_queue, deque):
536
+ self._call_queue = deque(self._call_queue)
537
+ self._replay_mode = replay_mode
538
+
539
+ self._params = None
540
+ self._named_params = None
541
+ self._return_value = None
542
+ self._exception = None
543
+ self._side_effects = None
544
+
545
+ def __call__(self, *params, **named_params):
546
+ """Log parameters and return the specified return value.
547
+
548
+ If the Mock(Anything/Object) associated with this call is in record mode,
549
+ this MockMethod will be pushed onto the expected call queue. If the mock
550
+ is in replay mode, this will pop a MockMethod off the top of the queue and
551
+ verify this call is equal to the expected call.
552
+
553
+ Raises:
554
+ UnexpectedMethodCall if this call is supposed to match an expected method
555
+ call and it does not.
556
+ """
557
+
558
+ self._params = params
559
+ self._named_params = named_params
560
+
561
+ if not self._replay_mode:
562
+ self._call_queue.append(self)
563
+ return self
564
+
565
+ expected_method = self._VerifyMethodCall()
566
+
567
+ if expected_method._side_effects:
568
+ expected_method._side_effects(*params, **named_params)
569
+
570
+ if expected_method._exception:
571
+ raise expected_method._exception
572
+
573
+ return expected_method._return_value
574
+
575
+ def __getattr__(self, name):
576
+ """Raise an AttributeError with a helpful message."""
577
+
578
+ raise AttributeError('MockMethod has no attribute "%s". '
579
+ 'Did you remember to put your mocks in replay mode?' % name)
580
+
581
+ def _PopNextMethod(self):
582
+ """Pop the next method from our call queue."""
583
+ try:
584
+ return self._call_queue.popleft()
585
+ except IndexError:
586
+ raise UnexpectedMethodCallError(self, None)
587
+
588
+ def _VerifyMethodCall(self):
589
+ """Verify the called method is expected.
590
+
591
+ This can be an ordered method, or part of an unordered set.
592
+
593
+ Returns:
594
+ The expected mock method.
595
+
596
+ Raises:
597
+ UnexpectedMethodCall if the method called was not expected.
598
+ """
599
+
600
+ expected = self._PopNextMethod()
601
+
602
+ # Loop here, because we might have a MethodGroup followed by another
603
+ # group.
604
+ while isinstance(expected, MethodGroup):
605
+ expected, method = expected.MethodCalled(self)
606
+ if method is not None:
607
+ return method
608
+
609
+ # This is a mock method, so just check equality.
610
+ if expected != self:
611
+ raise UnexpectedMethodCallError(self, expected)
612
+
613
+ return expected
614
+
615
+ def __str__(self):
616
+ params = ', '.join(
617
+ [repr(p) for p in self._params or []] +
618
+ ['%s=%r' % x for x in sorted((self._named_params or {}).items())])
619
+ desc = "%s(%s) -> %r" % (self._name, params, self._return_value)
620
+ return desc
621
+
622
+ def __eq__(self, rhs):
623
+ """Test whether this MockMethod is equivalent to another MockMethod.
624
+
625
+ Args:
626
+ # rhs: the right hand side of the test
627
+ rhs: MockMethod
628
+ """
629
+
630
+ return (isinstance(rhs, MockMethod) and
631
+ self._name == rhs._name and
632
+ self._params == rhs._params and
633
+ self._named_params == rhs._named_params)
634
+
635
+ def __ne__(self, rhs):
636
+ """Test whether this MockMethod is not equivalent to another MockMethod.
637
+
638
+ Args:
639
+ # rhs: the right hand side of the test
640
+ rhs: MockMethod
641
+ """
642
+
643
+ return not self == rhs
644
+
645
+ def GetPossibleGroup(self):
646
+ """Returns a possible group from the end of the call queue or None if no
647
+ other methods are on the stack.
648
+ """
649
+
650
+ # Remove this method from the tail of the queue so we can add it to a group.
651
+ this_method = self._call_queue.pop()
652
+ assert this_method == self
653
+
654
+ # Determine if the tail of the queue is a group, or just a regular ordered
655
+ # mock method.
656
+ group = None
657
+ try:
658
+ group = self._call_queue[-1]
659
+ except IndexError:
660
+ pass
661
+
662
+ return group
663
+
664
+ def _CheckAndCreateNewGroup(self, group_name, group_class):
665
+ """Checks if the last method (a possible group) is an instance of our
666
+ group_class. Adds the current method to this group or creates a new one.
667
+
668
+ Args:
669
+
670
+ group_name: the name of the group.
671
+ group_class: the class used to create instance of this new group
672
+ """
673
+ group = self.GetPossibleGroup()
674
+
675
+ # If this is a group, and it is the correct group, add the method.
676
+ if isinstance(group, group_class) and group.group_name() == group_name:
677
+ group.AddMethod(self)
678
+ return self
679
+
680
+ # Create a new group and add the method.
681
+ new_group = group_class(group_name)
682
+ new_group.AddMethod(self)
683
+ self._call_queue.append(new_group)
684
+ return self
685
+
686
+ def InAnyOrder(self, group_name="default"):
687
+ """Move this method into a group of unordered calls.
688
+
689
+ A group of unordered calls must be defined together, and must be executed
690
+ in full before the next expected method can be called. There can be
691
+ multiple groups that are expected serially, if they are given
692
+ different group names. The same group name can be reused if there is a
693
+ standard method call, or a group with a different name, spliced between
694
+ usages.
695
+
696
+ Args:
697
+ group_name: the name of the unordered group.
698
+
699
+ Returns:
700
+ self
701
+ """
702
+ return self._CheckAndCreateNewGroup(group_name, UnorderedGroup)
703
+
704
+ def MultipleTimes(self, group_name="default"):
705
+ """Move this method into group of calls which may be called multiple times.
706
+
707
+ A group of repeating calls must be defined together, and must be executed in
708
+ full before the next expected mehtod can be called.
709
+
710
+ Args:
711
+ group_name: the name of the unordered group.
712
+
713
+ Returns:
714
+ self
715
+ """
716
+ return self._CheckAndCreateNewGroup(group_name, MultipleTimesGroup)
717
+
718
+ def AndReturn(self, return_value):
719
+ """Set the value to return when this method is called.
720
+
721
+ Args:
722
+ # return_value can be anything.
723
+ """
724
+
725
+ self._return_value = return_value
726
+ return return_value
727
+
728
+ def AndRaise(self, exception):
729
+ """Set the exception to raise when this method is called.
730
+
731
+ Args:
732
+ # exception: the exception to raise when this method is called.
733
+ exception: Exception
734
+ """
735
+
736
+ self._exception = exception
737
+
738
+ def WithSideEffects(self, side_effects):
739
+ """Set the side effects that are simulated when this method is called.
740
+
741
+ Args:
742
+ side_effects: A callable which modifies the parameters or other relevant
743
+ state which a given test case depends on.
744
+
745
+ Returns:
746
+ Self for chaining with AndReturn and AndRaise.
747
+ """
748
+ self._side_effects = side_effects
749
+ return self
750
+
751
+ class Comparator:
752
+ """Base class for all Mox comparators.
753
+
754
+ A Comparator can be used as a parameter to a mocked method when the exact
755
+ value is not known. For example, the code you are testing might build up a
756
+ long SQL string that is passed to your mock DAO. You're only interested that
757
+ the IN clause contains the proper primary keys, so you can set your mock
758
+ up as follows:
759
+
760
+ mock_dao.RunQuery(StrContains('IN (1, 2, 4, 5)')).AndReturn(mock_result)
761
+
762
+ Now whatever query is passed in must contain the string 'IN (1, 2, 4, 5)'.
763
+
764
+ A Comparator may replace one or more parameters, for example:
765
+ # return at most 10 rows
766
+ mock_dao.RunQuery(StrContains('SELECT'), 10)
767
+
768
+ or
769
+
770
+ # Return some non-deterministic number of rows
771
+ mock_dao.RunQuery(StrContains('SELECT'), IsA(int))
772
+ """
773
+
774
+ def equals(self, rhs):
775
+ """Special equals method that all comparators must implement.
776
+
777
+ Args:
778
+ rhs: any python object
779
+ """
780
+
781
+ raise NotImplementedError, 'method must be implemented by a subclass.'
782
+
783
+ def __eq__(self, rhs):
784
+ return self.equals(rhs)
785
+
786
+ def __ne__(self, rhs):
787
+ return not self.equals(rhs)
788
+
789
+
790
+ class IsA(Comparator):
791
+ """This class wraps a basic Python type or class. It is used to verify
792
+ that a parameter is of the given type or class.
793
+
794
+ Example:
795
+ mock_dao.Connect(IsA(DbConnectInfo))
796
+ """
797
+
798
+ def __init__(self, class_name):
799
+ """Initialize IsA
800
+
801
+ Args:
802
+ class_name: basic python type or a class
803
+ """
804
+
805
+ self._class_name = class_name
806
+
807
+ def equals(self, rhs):
808
+ """Check to see if the RHS is an instance of class_name.
809
+
810
+ Args:
811
+ # rhs: the right hand side of the test
812
+ rhs: object
813
+
814
+ Returns:
815
+ bool
816
+ """
817
+
818
+ try:
819
+ return isinstance(rhs, self._class_name)
820
+ except TypeError:
821
+ # Check raw types if there was a type error. This is helpful for
822
+ # things like cStringIO.StringIO.
823
+ return type(rhs) == type(self._class_name)
824
+
825
+ def __repr__(self):
826
+ return str(self._class_name)
827
+
828
+ class IsAlmost(Comparator):
829
+ """Comparison class used to check whether a parameter is nearly equal
830
+ to a given value. Generally useful for floating point numbers.
831
+
832
+ Example mock_dao.SetTimeout((IsAlmost(3.9)))
833
+ """
834
+
835
+ def __init__(self, float_value, places=7):
836
+ """Initialize IsAlmost.
837
+
838
+ Args:
839
+ float_value: The value for making the comparison.
840
+ places: The number of decimal places to round to.
841
+ """
842
+
843
+ self._float_value = float_value
844
+ self._places = places
845
+
846
+ def equals(self, rhs):
847
+ """Check to see if RHS is almost equal to float_value
848
+
849
+ Args:
850
+ rhs: the value to compare to float_value
851
+
852
+ Returns:
853
+ bool
854
+ """
855
+
856
+ try:
857
+ return round(rhs-self._float_value, self._places) == 0
858
+ except TypeError:
859
+ # This is probably because either float_value or rhs is not a number.
860
+ return False
861
+
862
+ def __repr__(self):
863
+ return str(self._float_value)
864
+
865
+ class StrContains(Comparator):
866
+ """Comparison class used to check whether a substring exists in a
867
+ string parameter. This can be useful in mocking a database with SQL
868
+ passed in as a string parameter, for example.
869
+
870
+ Example:
871
+ mock_dao.RunQuery(StrContains('IN (1, 2, 4, 5)')).AndReturn(mock_result)
872
+ """
873
+
874
+ def __init__(self, search_string):
875
+ """Initialize.
876
+
877
+ Args:
878
+ # search_string: the string you are searching for
879
+ search_string: str
880
+ """
881
+
882
+ self._search_string = search_string
883
+
884
+ def equals(self, rhs):
885
+ """Check to see if the search_string is contained in the rhs string.
886
+
887
+ Args:
888
+ # rhs: the right hand side of the test
889
+ rhs: object
890
+
891
+ Returns:
892
+ bool
893
+ """
894
+
895
+ try:
896
+ return rhs.find(self._search_string) > -1
897
+ except Exception:
898
+ return False
899
+
900
+ def __repr__(self):
901
+ return '<str containing \'%s\'>' % self._search_string
902
+
903
+
904
+ class Regex(Comparator):
905
+ """Checks if a string matches a regular expression.
906
+
907
+ This uses a given regular expression to determine equality.
908
+ """
909
+
910
+ def __init__(self, pattern, flags=0):
911
+ """Initialize.
912
+
913
+ Args:
914
+ # pattern is the regular expression to search for
915
+ pattern: str
916
+ # flags passed to re.compile function as the second argument
917
+ flags: int
918
+ """
919
+
920
+ self.regex = re.compile(pattern, flags=flags)
921
+
922
+ def equals(self, rhs):
923
+ """Check to see if rhs matches regular expression pattern.
924
+
925
+ Returns:
926
+ bool
927
+ """
928
+
929
+ return self.regex.search(rhs) is not None
930
+
931
+ def __repr__(self):
932
+ s = '<regular expression \'%s\'' % self.regex.pattern
933
+ if self.regex.flags:
934
+ s += ', flags=%d' % self.regex.flags
935
+ s += '>'
936
+ return s
937
+
938
+
939
+ class In(Comparator):
940
+ """Checks whether an item (or key) is in a list (or dict) parameter.
941
+
942
+ Example:
943
+ mock_dao.GetUsersInfo(In('expectedUserName')).AndReturn(mock_result)
944
+ """
945
+
946
+ def __init__(self, key):
947
+ """Initialize.
948
+
949
+ Args:
950
+ # key is any thing that could be in a list or a key in a dict
951
+ """
952
+
953
+ self._key = key
954
+
955
+ def equals(self, rhs):
956
+ """Check to see whether key is in rhs.
957
+
958
+ Args:
959
+ rhs: dict
960
+
961
+ Returns:
962
+ bool
963
+ """
964
+
965
+ return self._key in rhs
966
+
967
+ def __repr__(self):
968
+ return '<sequence or map containing \'%s\'>' % self._key
969
+
970
+
971
+ class ContainsKeyValue(Comparator):
972
+ """Checks whether a key/value pair is in a dict parameter.
973
+
974
+ Example:
975
+ mock_dao.UpdateUsers(ContainsKeyValue('stevepm', stevepm_user_info))
976
+ """
977
+
978
+ def __init__(self, key, value):
979
+ """Initialize.
980
+
981
+ Args:
982
+ # key: a key in a dict
983
+ # value: the corresponding value
984
+ """
985
+
986
+ self._key = key
987
+ self._value = value
988
+
989
+ def equals(self, rhs):
990
+ """Check whether the given key/value pair is in the rhs dict.
991
+
992
+ Returns:
993
+ bool
994
+ """
995
+
996
+ try:
997
+ return rhs[self._key] == self._value
998
+ except Exception:
999
+ return False
1000
+
1001
+ def __repr__(self):
1002
+ return '<map containing the entry \'%s: %s\'>' % (self._key, self._value)
1003
+
1004
+
1005
+ class SameElementsAs(Comparator):
1006
+ """Checks whether iterables contain the same elements (ignoring order).
1007
+
1008
+ Example:
1009
+ mock_dao.ProcessUsers(SameElementsAs('stevepm', 'salomaki'))
1010
+ """
1011
+
1012
+ def __init__(self, expected_seq):
1013
+ """Initialize.
1014
+
1015
+ Args:
1016
+ expected_seq: a sequence
1017
+ """
1018
+
1019
+ self._expected_seq = expected_seq
1020
+
1021
+ def equals(self, actual_seq):
1022
+ """Check to see whether actual_seq has same elements as expected_seq.
1023
+
1024
+ Args:
1025
+ actual_seq: sequence
1026
+
1027
+ Returns:
1028
+ bool
1029
+ """
1030
+
1031
+ try:
1032
+ expected = dict([(element, None) for element in self._expected_seq])
1033
+ actual = dict([(element, None) for element in actual_seq])
1034
+ except TypeError:
1035
+ # Fall back to slower list-compare if any of the objects are unhashable.
1036
+ expected = list(self._expected_seq)
1037
+ actual = list(actual_seq)
1038
+ expected.sort()
1039
+ actual.sort()
1040
+ return expected == actual
1041
+
1042
+ def __repr__(self):
1043
+ return '<sequence with same elements as \'%s\'>' % self._expected_seq
1044
+
1045
+
1046
+ class And(Comparator):
1047
+ """Evaluates one or more Comparators on RHS and returns an AND of the results.
1048
+ """
1049
+
1050
+ def __init__(self, *args):
1051
+ """Initialize.
1052
+
1053
+ Args:
1054
+ *args: One or more Comparator
1055
+ """
1056
+
1057
+ self._comparators = args
1058
+
1059
+ def equals(self, rhs):
1060
+ """Checks whether all Comparators are equal to rhs.
1061
+
1062
+ Args:
1063
+ # rhs: can be anything
1064
+
1065
+ Returns:
1066
+ bool
1067
+ """
1068
+
1069
+ for comparator in self._comparators:
1070
+ if not comparator.equals(rhs):
1071
+ return False
1072
+
1073
+ return True
1074
+
1075
+ def __repr__(self):
1076
+ return '<AND %s>' % str(self._comparators)
1077
+
1078
+
1079
+ class Or(Comparator):
1080
+ """Evaluates one or more Comparators on RHS and returns an OR of the results.
1081
+ """
1082
+
1083
+ def __init__(self, *args):
1084
+ """Initialize.
1085
+
1086
+ Args:
1087
+ *args: One or more Mox comparators
1088
+ """
1089
+
1090
+ self._comparators = args
1091
+
1092
+ def equals(self, rhs):
1093
+ """Checks whether any Comparator is equal to rhs.
1094
+
1095
+ Args:
1096
+ # rhs: can be anything
1097
+
1098
+ Returns:
1099
+ bool
1100
+ """
1101
+
1102
+ for comparator in self._comparators:
1103
+ if comparator.equals(rhs):
1104
+ return True
1105
+
1106
+ return False
1107
+
1108
+ def __repr__(self):
1109
+ return '<OR %s>' % str(self._comparators)
1110
+
1111
+
1112
+ class Func(Comparator):
1113
+ """Call a function that should verify the parameter passed in is correct.
1114
+
1115
+ You may need the ability to perform more advanced operations on the parameter
1116
+ in order to validate it. You can use this to have a callable validate any
1117
+ parameter. The callable should return either True or False.
1118
+
1119
+
1120
+ Example:
1121
+
1122
+ def myParamValidator(param):
1123
+ # Advanced logic here
1124
+ return True
1125
+
1126
+ mock_dao.DoSomething(Func(myParamValidator), true)
1127
+ """
1128
+
1129
+ def __init__(self, func):
1130
+ """Initialize.
1131
+
1132
+ Args:
1133
+ func: callable that takes one parameter and returns a bool
1134
+ """
1135
+
1136
+ self._func = func
1137
+
1138
+ def equals(self, rhs):
1139
+ """Test whether rhs passes the function test.
1140
+
1141
+ rhs is passed into func.
1142
+
1143
+ Args:
1144
+ rhs: any python object
1145
+
1146
+ Returns:
1147
+ the result of func(rhs)
1148
+ """
1149
+
1150
+ return self._func(rhs)
1151
+
1152
+ def __repr__(self):
1153
+ return str(self._func)
1154
+
1155
+
1156
+ class IgnoreArg(Comparator):
1157
+ """Ignore an argument.
1158
+
1159
+ This can be used when we don't care about an argument of a method call.
1160
+
1161
+ Example:
1162
+ # Check if CastMagic is called with 3 as first arg and 'disappear' as third.
1163
+ mymock.CastMagic(3, IgnoreArg(), 'disappear')
1164
+ """
1165
+
1166
+ def equals(self, unused_rhs):
1167
+ """Ignores arguments and returns True.
1168
+
1169
+ Args:
1170
+ unused_rhs: any python object
1171
+
1172
+ Returns:
1173
+ always returns True
1174
+ """
1175
+
1176
+ return True
1177
+
1178
+ def __repr__(self):
1179
+ return '<IgnoreArg>'
1180
+
1181
+
1182
+ class MethodGroup(object):
1183
+ """Base class containing common behaviour for MethodGroups."""
1184
+
1185
+ def __init__(self, group_name):
1186
+ self._group_name = group_name
1187
+
1188
+ def group_name(self):
1189
+ return self._group_name
1190
+
1191
+ def __str__(self):
1192
+ return '<%s "%s">' % (self.__class__.__name__, self._group_name)
1193
+
1194
+ def AddMethod(self, mock_method):
1195
+ raise NotImplementedError
1196
+
1197
+ def MethodCalled(self, mock_method):
1198
+ raise NotImplementedError
1199
+
1200
+ def IsSatisfied(self):
1201
+ raise NotImplementedError
1202
+
1203
+ class UnorderedGroup(MethodGroup):
1204
+ """UnorderedGroup holds a set of method calls that may occur in any order.
1205
+
1206
+ This construct is helpful for non-deterministic events, such as iterating
1207
+ over the keys of a dict.
1208
+ """
1209
+
1210
+ def __init__(self, group_name):
1211
+ super(UnorderedGroup, self).__init__(group_name)
1212
+ self._methods = []
1213
+
1214
+ def AddMethod(self, mock_method):
1215
+ """Add a method to this group.
1216
+
1217
+ Args:
1218
+ mock_method: A mock method to be added to this group.
1219
+ """
1220
+
1221
+ self._methods.append(mock_method)
1222
+
1223
+ def MethodCalled(self, mock_method):
1224
+ """Remove a method call from the group.
1225
+
1226
+ If the method is not in the set, an UnexpectedMethodCallError will be
1227
+ raised.
1228
+
1229
+ Args:
1230
+ mock_method: a mock method that should be equal to a method in the group.
1231
+
1232
+ Returns:
1233
+ The mock method from the group
1234
+
1235
+ Raises:
1236
+ UnexpectedMethodCallError if the mock_method was not in the group.
1237
+ """
1238
+
1239
+ # Check to see if this method exists, and if so, remove it from the set
1240
+ # and return it.
1241
+ for method in self._methods:
1242
+ if method == mock_method:
1243
+ # Remove the called mock_method instead of the method in the group.
1244
+ # The called method will match any comparators when equality is checked
1245
+ # during removal. The method in the group could pass a comparator to
1246
+ # another comparator during the equality check.
1247
+ self._methods.remove(mock_method)
1248
+
1249
+ # If this group is not empty, put it back at the head of the queue.
1250
+ if not self.IsSatisfied():
1251
+ mock_method._call_queue.appendleft(self)
1252
+
1253
+ return self, method
1254
+
1255
+ raise UnexpectedMethodCallError(mock_method, self)
1256
+
1257
+ def IsSatisfied(self):
1258
+ """Return True if there are not any methods in this group."""
1259
+
1260
+ return len(self._methods) == 0
1261
+
1262
+
1263
+ class MultipleTimesGroup(MethodGroup):
1264
+ """MultipleTimesGroup holds methods that may be called any number of times.
1265
+
1266
+ Note: Each method must be called at least once.
1267
+
1268
+ This is helpful, if you don't know or care how many times a method is called.
1269
+ """
1270
+
1271
+ def __init__(self, group_name):
1272
+ super(MultipleTimesGroup, self).__init__(group_name)
1273
+ self._methods = set()
1274
+ self._methods_called = set()
1275
+
1276
+ def AddMethod(self, mock_method):
1277
+ """Add a method to this group.
1278
+
1279
+ Args:
1280
+ mock_method: A mock method to be added to this group.
1281
+ """
1282
+
1283
+ self._methods.add(mock_method)
1284
+
1285
+ def MethodCalled(self, mock_method):
1286
+ """Remove a method call from the group.
1287
+
1288
+ If the method is not in the set, an UnexpectedMethodCallError will be
1289
+ raised.
1290
+
1291
+ Args:
1292
+ mock_method: a mock method that should be equal to a method in the group.
1293
+
1294
+ Returns:
1295
+ The mock method from the group
1296
+
1297
+ Raises:
1298
+ UnexpectedMethodCallError if the mock_method was not in the group.
1299
+ """
1300
+
1301
+ # Check to see if this method exists, and if so add it to the set of
1302
+ # called methods.
1303
+
1304
+ for method in self._methods:
1305
+ if method == mock_method:
1306
+ self._methods_called.add(mock_method)
1307
+ # Always put this group back on top of the queue, because we don't know
1308
+ # when we are done.
1309
+ mock_method._call_queue.appendleft(self)
1310
+ return self, method
1311
+
1312
+ if self.IsSatisfied():
1313
+ next_method = mock_method._PopNextMethod();
1314
+ return next_method, None
1315
+ else:
1316
+ raise UnexpectedMethodCallError(mock_method, self)
1317
+
1318
+ def IsSatisfied(self):
1319
+ """Return True if all methods in this group are called at least once."""
1320
+ # NOTE(psycho): We can't use the simple set difference here because we want
1321
+ # to match different parameters which are considered the same e.g. IsA(str)
1322
+ # and some string. This solution is O(n^2) but n should be small.
1323
+ tmp = self._methods.copy()
1324
+ for called in self._methods_called:
1325
+ for expected in tmp:
1326
+ if called == expected:
1327
+ tmp.remove(expected)
1328
+ if not tmp:
1329
+ return True
1330
+ break
1331
+ return False
1332
+
1333
+
1334
+ class MoxMetaTestBase(type):
1335
+ """Metaclass to add mox cleanup and verification to every test.
1336
+
1337
+ As the mox unit testing class is being constructed (MoxTestBase or a
1338
+ subclass), this metaclass will modify all test functions to call the
1339
+ CleanUpMox method of the test class after they finish. This means that
1340
+ unstubbing and verifying will happen for every test with no additional code,
1341
+ and any failures will result in test failures as opposed to errors.
1342
+ """
1343
+
1344
+ def __init__(cls, name, bases, d):
1345
+ type.__init__(cls, name, bases, d)
1346
+
1347
+ # also get all the attributes from the base classes to account
1348
+ # for a case when test class is not the immediate child of MoxTestBase
1349
+ for base in bases:
1350
+ for attr_name in dir(base):
1351
+ d[attr_name] = getattr(base, attr_name)
1352
+
1353
+ for func_name, func in d.items():
1354
+ if func_name.startswith('test') and callable(func):
1355
+ setattr(cls, func_name, MoxMetaTestBase.CleanUpTest(cls, func))
1356
+
1357
+ @staticmethod
1358
+ def CleanUpTest(cls, func):
1359
+ """Adds Mox cleanup code to any MoxTestBase method.
1360
+
1361
+ Always unsets stubs after a test. Will verify all mocks for tests that
1362
+ otherwise pass.
1363
+
1364
+ Args:
1365
+ cls: MoxTestBase or subclass; the class whose test method we are altering.
1366
+ func: method; the method of the MoxTestBase test class we wish to alter.
1367
+
1368
+ Returns:
1369
+ The modified method.
1370
+ """
1371
+ def new_method(self, *args, **kwargs):
1372
+ mox_obj = getattr(self, 'mox', None)
1373
+ cleanup_mox = False
1374
+ if mox_obj and isinstance(mox_obj, Mox):
1375
+ cleanup_mox = True
1376
+ try:
1377
+ func(self, *args, **kwargs)
1378
+ finally:
1379
+ if cleanup_mox:
1380
+ mox_obj.UnsetStubs()
1381
+ if cleanup_mox:
1382
+ mox_obj.VerifyAll()
1383
+ new_method.__name__ = func.__name__
1384
+ new_method.__doc__ = func.__doc__
1385
+ new_method.__module__ = func.__module__
1386
+ return new_method
1387
+
1388
+
1389
+ class MoxTestBase(unittest.TestCase):
1390
+ """Convenience test class to make stubbing easier.
1391
+
1392
+ Sets up a "mox" attribute which is an instance of Mox - any mox tests will
1393
+ want this. Also automatically unsets any stubs and verifies that all mock
1394
+ methods have been called at the end of each test, eliminating boilerplate
1395
+ code.
1396
+ """
1397
+
1398
+ __metaclass__ = MoxMetaTestBase
1399
+
1400
+ def setUp(self):
1401
+ self.mox = Mox()