auser-poolparty 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (424) hide show
  1. data/VERSION.yml +1 -1
  2. data/bin/cloud-compile +6 -1
  3. data/config/jeweler.rb +1 -3
  4. data/lib/cloud_providers/cloud_provider_instance.rb +11 -1
  5. data/lib/dependency_resolvers/chef/resources/chef_recipe.rb +51 -0
  6. data/lib/dependency_resolvers/chef.rb +12 -3
  7. data/lib/mixins/callbacks.rb +6 -2
  8. data/lib/poolparty/plugins/apache2/passenger_site.rb +2 -2
  9. data/test/fixtures/chef/recipes/sudo/attributes/sudoers.rb +30 -0
  10. data/test/fixtures/chef/recipes/sudo/recipes/default.rb +33 -0
  11. data/test/fixtures/chef/recipes/sudo/templates/default/sudoers.erb +22 -0
  12. data/test/lib/dependency_resolvers/chef/resources/chef_recipe_test.rb +21 -0
  13. data/test/lib/dependency_resolvers/chef_test.rb +8 -1
  14. data/vendor/gems/thrift/CHANGELOG +1 -0
  15. data/vendor/gems/thrift/Makefile.am +25 -6
  16. data/vendor/gems/thrift/Manifest +81 -0
  17. data/vendor/gems/thrift/README +17 -111
  18. data/vendor/gems/thrift/Rakefile +104 -0
  19. data/vendor/gems/thrift/{lib/hs/Setup.lhs → benchmark/Benchmark.thrift} +5 -4
  20. data/vendor/gems/thrift/benchmark/benchmark.rb +271 -0
  21. data/vendor/gems/thrift/benchmark/client.rb +74 -0
  22. data/vendor/gems/thrift/benchmark/server.rb +82 -0
  23. data/vendor/gems/thrift/benchmark/thin_server.rb +44 -0
  24. data/vendor/gems/thrift/ext/binary_protocol_accelerated.c +474 -0
  25. data/vendor/gems/thrift/{lib/cocoa/src/protocol/TProtocolException.m → ext/binary_protocol_accelerated.h} +1 -4
  26. data/vendor/gems/thrift/ext/compact_protocol.c +665 -0
  27. data/vendor/gems/thrift/{lib/cocoa/src/protocol/TProtocolException.h → ext/compact_protocol.h} +1 -6
  28. data/vendor/gems/thrift/ext/constants.h +95 -0
  29. data/vendor/gems/thrift/{contrib/fb303/Makefile.am → ext/extconf.rb} +8 -13
  30. data/vendor/gems/thrift/{compiler/cpp/src/platform.h → ext/macros.h} +18 -13
  31. data/vendor/gems/thrift/ext/memory_buffer.c +76 -0
  32. data/vendor/gems/thrift/{lib/csharp/src/Protocol/TMessageType.cs → ext/memory_buffer.h} +2 -13
  33. data/vendor/gems/thrift/ext/protocol.c +185 -0
  34. data/vendor/gems/thrift/{lib/csharp/src/TProcessor.cs → ext/protocol.h} +2 -11
  35. data/vendor/gems/thrift/ext/struct.c +606 -0
  36. data/vendor/gems/thrift/ext/struct.h +67 -0
  37. data/vendor/gems/thrift/ext/thrift_native.c +194 -0
  38. data/vendor/gems/thrift/lib/thrift/client.rb +62 -0
  39. data/vendor/gems/thrift/{contrib/fb303/py/fb303_scripts/__init__.py → lib/thrift/core_ext/fixnum.rb} +13 -4
  40. data/vendor/gems/thrift/{contrib/fb303/global_footer.mk → lib/thrift/core_ext.rb} +4 -2
  41. data/vendor/gems/thrift/lib/thrift/exceptions.rb +82 -0
  42. data/vendor/gems/thrift/lib/thrift/processor.rb +57 -0
  43. data/vendor/gems/thrift/lib/thrift/protocol/base_protocol.rb +290 -0
  44. data/vendor/gems/thrift/lib/thrift/protocol/binary_protocol.rb +225 -0
  45. data/vendor/gems/thrift/{cleanup.sh → lib/thrift/protocol/binary_protocol_accelerated.rb} +19 -42
  46. data/vendor/gems/thrift/lib/thrift/protocol/compact_protocol.rb +422 -0
  47. data/vendor/gems/thrift/lib/thrift/serializer/deserializer.rb +33 -0
  48. data/vendor/gems/thrift/{bootstrap.sh → lib/thrift/serializer/serializer.rb} +17 -18
  49. data/vendor/gems/thrift/lib/thrift/server/base_server.rb +31 -0
  50. data/vendor/gems/thrift/lib/thrift/server/mongrel_http_server.rb +58 -0
  51. data/vendor/gems/thrift/lib/thrift/server/nonblocking_server.rb +296 -0
  52. data/vendor/gems/thrift/lib/thrift/server/simple_server.rb +43 -0
  53. data/vendor/gems/thrift/lib/thrift/server/thread_pool_server.rb +75 -0
  54. data/vendor/gems/thrift/lib/thrift/server/threaded_server.rb +47 -0
  55. data/vendor/gems/thrift/lib/thrift/struct.rb +298 -0
  56. data/vendor/gems/thrift/{contrib/fb303/bootstrap.sh → lib/thrift/thrift_native.rb} +5 -7
  57. data/vendor/gems/thrift/lib/{erl/Makefile → thrift/transport/base_server_transport.rb} +20 -20
  58. data/vendor/gems/thrift/lib/thrift/transport/base_transport.rb +70 -0
  59. data/vendor/gems/thrift/lib/thrift/transport/buffered_transport.rb +77 -0
  60. data/vendor/gems/thrift/lib/thrift/transport/framed_transport.rb +90 -0
  61. data/vendor/gems/thrift/lib/thrift/transport/http_client_transport.rb +45 -0
  62. data/vendor/gems/thrift/lib/thrift/transport/io_stream_transport.rb +39 -0
  63. data/vendor/gems/thrift/lib/thrift/transport/memory_buffer_transport.rb +96 -0
  64. data/vendor/gems/thrift/lib/thrift/transport/server_socket.rb +63 -0
  65. data/vendor/gems/thrift/lib/thrift/transport/socket.rb +136 -0
  66. data/vendor/gems/thrift/lib/{java/Makefile.am → thrift/transport/unix_server_socket.rb} +39 -17
  67. data/vendor/gems/thrift/{contrib/fb303/global_header.mk → lib/thrift/transport/unix_socket.rb} +23 -21
  68. data/vendor/gems/thrift/lib/thrift/types.rb +101 -0
  69. data/vendor/gems/thrift/lib/thrift.rb +59 -0
  70. data/vendor/gems/thrift/script/proto_benchmark.rb +121 -0
  71. data/vendor/gems/thrift/{lib/Makefile.am → script/read_struct.rb} +24 -36
  72. data/vendor/gems/thrift/{contrib/fb303/py/setup.py → script/write_struct.rb} +8 -5
  73. data/vendor/gems/thrift/setup.rb +1585 -0
  74. data/vendor/gems/thrift/spec/ThriftSpec.thrift +84 -0
  75. data/vendor/gems/thrift/spec/base_protocol_spec.rb +160 -0
  76. data/vendor/gems/thrift/spec/base_transport_spec.rb +351 -0
  77. data/vendor/gems/thrift/{contrib/fb303/py/Makefile.am → spec/binary_protocol_accelerated_spec.rb} +22 -25
  78. data/vendor/gems/thrift/spec/binary_protocol_spec.rb +63 -0
  79. data/vendor/gems/thrift/spec/binary_protocol_spec_shared.rb +375 -0
  80. data/vendor/gems/thrift/spec/client_spec.rb +100 -0
  81. data/vendor/gems/thrift/spec/compact_protocol_spec.rb +117 -0
  82. data/vendor/gems/thrift/spec/exception_spec.rb +142 -0
  83. data/vendor/gems/thrift/spec/http_client_spec.rb +49 -0
  84. data/vendor/gems/thrift/spec/mongrel_http_server_spec.rb +117 -0
  85. data/vendor/gems/thrift/spec/nonblocking_server_spec.rb +265 -0
  86. data/vendor/gems/thrift/spec/processor_spec.rb +83 -0
  87. data/vendor/gems/thrift/spec/serializer_spec.rb +69 -0
  88. data/vendor/gems/thrift/spec/server_socket_spec.rb +80 -0
  89. data/vendor/gems/thrift/spec/server_spec.rb +160 -0
  90. data/vendor/gems/thrift/spec/socket_spec.rb +61 -0
  91. data/vendor/gems/thrift/spec/socket_spec_shared.rb +104 -0
  92. data/vendor/gems/thrift/spec/spec_helper.rb +60 -0
  93. data/vendor/gems/thrift/spec/struct_spec.rb +252 -0
  94. data/vendor/gems/thrift/spec/types_spec.rb +116 -0
  95. data/vendor/gems/thrift/spec/unix_socket_spec.rb +108 -0
  96. data/vendor/gems/trollop/FAQ.txt +84 -0
  97. data/vendor/gems/trollop/History.txt +101 -0
  98. data/vendor/gems/trollop/Manifest.txt +7 -0
  99. data/vendor/gems/trollop/README.txt +40 -0
  100. data/vendor/gems/trollop/Rakefile +36 -0
  101. data/vendor/gems/trollop/lib/trollop.rb +739 -0
  102. data/vendor/gems/trollop/release-script.txt +13 -0
  103. data/vendor/gems/trollop/test/test_trollop.rb +1048 -0
  104. data/vendor/gems/trollop/www/index.html +172 -0
  105. metadata +123 -347
  106. data/vendor/gems/thrift/CHANGES +0 -35
  107. data/vendor/gems/thrift/CONTRIBUTORS +0 -77
  108. data/vendor/gems/thrift/DISCLAIMER +0 -6
  109. data/vendor/gems/thrift/LICENSE +0 -202
  110. data/vendor/gems/thrift/NEWS +0 -79
  111. data/vendor/gems/thrift/NOTICE +0 -26
  112. data/vendor/gems/thrift/aclocal/ax_boost_base.m4 +0 -198
  113. data/vendor/gems/thrift/aclocal/ax_javac_and_java.m4 +0 -107
  114. data/vendor/gems/thrift/aclocal/ax_lib_event.m4 +0 -194
  115. data/vendor/gems/thrift/aclocal/ax_lib_zlib.m4 +0 -173
  116. data/vendor/gems/thrift/aclocal/ax_signed_right_shift.m4 +0 -127
  117. data/vendor/gems/thrift/aclocal/ax_thrift_internal.m4 +0 -39
  118. data/vendor/gems/thrift/compiler/cpp/Makefile.am +0 -136
  119. data/vendor/gems/thrift/compiler/cpp/README +0 -39
  120. data/vendor/gems/thrift/compiler/cpp/src/generate/t_cocoa_generator.cc +0 -2331
  121. data/vendor/gems/thrift/compiler/cpp/src/generate/t_cpp_generator.cc +0 -3003
  122. data/vendor/gems/thrift/compiler/cpp/src/generate/t_csharp_generator.cc +0 -1700
  123. data/vendor/gems/thrift/compiler/cpp/src/generate/t_erl_generator.cc +0 -932
  124. data/vendor/gems/thrift/compiler/cpp/src/generate/t_generator.cc +0 -173
  125. data/vendor/gems/thrift/compiler/cpp/src/generate/t_generator.h +0 -321
  126. data/vendor/gems/thrift/compiler/cpp/src/generate/t_hs_generator.cc +0 -1445
  127. data/vendor/gems/thrift/compiler/cpp/src/generate/t_html_generator.cc +0 -637
  128. data/vendor/gems/thrift/compiler/cpp/src/generate/t_java_generator.cc +0 -3069
  129. data/vendor/gems/thrift/compiler/cpp/src/generate/t_ocaml_generator.cc +0 -1673
  130. data/vendor/gems/thrift/compiler/cpp/src/generate/t_oop_generator.h +0 -77
  131. data/vendor/gems/thrift/compiler/cpp/src/generate/t_perl_generator.cc +0 -1812
  132. data/vendor/gems/thrift/compiler/cpp/src/generate/t_php_generator.cc +0 -2281
  133. data/vendor/gems/thrift/compiler/cpp/src/generate/t_py_generator.cc +0 -2310
  134. data/vendor/gems/thrift/compiler/cpp/src/generate/t_rb_generator.cc +0 -1114
  135. data/vendor/gems/thrift/compiler/cpp/src/generate/t_st_generator.cc +0 -1071
  136. data/vendor/gems/thrift/compiler/cpp/src/generate/t_xsd_generator.cc +0 -354
  137. data/vendor/gems/thrift/compiler/cpp/src/globals.h +0 -117
  138. data/vendor/gems/thrift/compiler/cpp/src/main.cc +0 -1207
  139. data/vendor/gems/thrift/compiler/cpp/src/main.h +0 -103
  140. data/vendor/gems/thrift/compiler/cpp/src/md5.c +0 -381
  141. data/vendor/gems/thrift/compiler/cpp/src/md5.h +0 -91
  142. data/vendor/gems/thrift/compiler/cpp/src/parse/t_base_type.h +0 -137
  143. data/vendor/gems/thrift/compiler/cpp/src/parse/t_const.h +0 -59
  144. data/vendor/gems/thrift/compiler/cpp/src/parse/t_const_value.h +0 -121
  145. data/vendor/gems/thrift/compiler/cpp/src/parse/t_container.h +0 -56
  146. data/vendor/gems/thrift/compiler/cpp/src/parse/t_doc.h +0 -51
  147. data/vendor/gems/thrift/compiler/cpp/src/parse/t_enum.h +0 -59
  148. data/vendor/gems/thrift/compiler/cpp/src/parse/t_enum_value.h +0 -64
  149. data/vendor/gems/thrift/compiler/cpp/src/parse/t_field.h +0 -150
  150. data/vendor/gems/thrift/compiler/cpp/src/parse/t_function.h +0 -93
  151. data/vendor/gems/thrift/compiler/cpp/src/parse/t_list.h +0 -56
  152. data/vendor/gems/thrift/compiler/cpp/src/parse/t_map.h +0 -64
  153. data/vendor/gems/thrift/compiler/cpp/src/parse/t_program.h +0 -223
  154. data/vendor/gems/thrift/compiler/cpp/src/parse/t_scope.h +0 -86
  155. data/vendor/gems/thrift/compiler/cpp/src/parse/t_service.h +0 -68
  156. data/vendor/gems/thrift/compiler/cpp/src/parse/t_set.h +0 -55
  157. data/vendor/gems/thrift/compiler/cpp/src/parse/t_struct.h +0 -127
  158. data/vendor/gems/thrift/compiler/cpp/src/parse/t_type.h +0 -176
  159. data/vendor/gems/thrift/compiler/cpp/src/parse/t_typedef.h +0 -70
  160. data/vendor/gems/thrift/compiler/cpp/src/thriftl.ll +0 -303
  161. data/vendor/gems/thrift/compiler/cpp/src/thrifty.yy +0 -1140
  162. data/vendor/gems/thrift/configure.ac +0 -255
  163. data/vendor/gems/thrift/contrib/fb303/LICENSE +0 -16
  164. data/vendor/gems/thrift/contrib/fb303/README +0 -37
  165. data/vendor/gems/thrift/contrib/fb303/acinclude.m4 +0 -258
  166. data/vendor/gems/thrift/contrib/fb303/aclocal/ax_boost_base.m4 +0 -198
  167. data/vendor/gems/thrift/contrib/fb303/configure.ac +0 -115
  168. data/vendor/gems/thrift/contrib/fb303/cpp/FacebookBase.cpp +0 -124
  169. data/vendor/gems/thrift/contrib/fb303/cpp/FacebookBase.h +0 -103
  170. data/vendor/gems/thrift/contrib/fb303/cpp/Makefile.am +0 -84
  171. data/vendor/gems/thrift/contrib/fb303/cpp/ServiceTracker.cpp +0 -481
  172. data/vendor/gems/thrift/contrib/fb303/cpp/ServiceTracker.h +0 -215
  173. data/vendor/gems/thrift/contrib/fb303/if/fb303.thrift +0 -112
  174. data/vendor/gems/thrift/contrib/fb303/java/FacebookBase.java +0 -103
  175. data/vendor/gems/thrift/contrib/fb303/java/build.xml +0 -84
  176. data/vendor/gems/thrift/contrib/fb303/php/FacebookBase.php +0 -89
  177. data/vendor/gems/thrift/contrib/fb303/py/fb303/FacebookBase.py +0 -82
  178. data/vendor/gems/thrift/contrib/fb303/py/fb303_scripts/fb303_simple_mgmt.py +0 -195
  179. data/vendor/gems/thrift/contrib/thrift.el +0 -126
  180. data/vendor/gems/thrift/contrib/thrift.spec +0 -206
  181. data/vendor/gems/thrift/contrib/thrift.vim +0 -91
  182. data/vendor/gems/thrift/contrib/thrift_dump.cpp +0 -91
  183. data/vendor/gems/thrift/doc/lgpl-2.1.txt +0 -504
  184. data/vendor/gems/thrift/doc/otp-base-license.txt +0 -20
  185. data/vendor/gems/thrift/doc/thrift.bnf +0 -96
  186. data/vendor/gems/thrift/doc/thrift.tex +0 -1057
  187. data/vendor/gems/thrift/lib/cocoa/README +0 -21
  188. data/vendor/gems/thrift/lib/cocoa/src/TApplicationException.h +0 -44
  189. data/vendor/gems/thrift/lib/cocoa/src/TApplicationException.m +0 -130
  190. data/vendor/gems/thrift/lib/cocoa/src/TException.h +0 -34
  191. data/vendor/gems/thrift/lib/cocoa/src/TException.m +0 -64
  192. data/vendor/gems/thrift/lib/cocoa/src/TProcessor.h +0 -29
  193. data/vendor/gems/thrift/lib/cocoa/src/TProcessorFactory.h +0 -27
  194. data/vendor/gems/thrift/lib/cocoa/src/TSharedProcessorFactory.h +0 -27
  195. data/vendor/gems/thrift/lib/cocoa/src/TSharedProcessorFactory.m +0 -51
  196. data/vendor/gems/thrift/lib/cocoa/src/protocol/TBinaryProtocol.h +0 -51
  197. data/vendor/gems/thrift/lib/cocoa/src/protocol/TBinaryProtocol.m +0 -477
  198. data/vendor/gems/thrift/lib/cocoa/src/protocol/TProtocol.h +0 -148
  199. data/vendor/gems/thrift/lib/cocoa/src/protocol/TProtocolFactory.h +0 -29
  200. data/vendor/gems/thrift/lib/cocoa/src/protocol/TProtocolUtil.h +0 -29
  201. data/vendor/gems/thrift/lib/cocoa/src/protocol/TProtocolUtil.m +0 -104
  202. data/vendor/gems/thrift/lib/cocoa/src/server/TSocketServer.h +0 -50
  203. data/vendor/gems/thrift/lib/cocoa/src/server/TSocketServer.m +0 -153
  204. data/vendor/gems/thrift/lib/cocoa/src/transport/THTTPClient.h +0 -42
  205. data/vendor/gems/thrift/lib/cocoa/src/transport/THTTPClient.m +0 -159
  206. data/vendor/gems/thrift/lib/cocoa/src/transport/TNSFileHandleTransport.h +0 -35
  207. data/vendor/gems/thrift/lib/cocoa/src/transport/TNSFileHandleTransport.m +0 -91
  208. data/vendor/gems/thrift/lib/cocoa/src/transport/TNSStreamTransport.h +0 -38
  209. data/vendor/gems/thrift/lib/cocoa/src/transport/TNSStreamTransport.m +0 -89
  210. data/vendor/gems/thrift/lib/cocoa/src/transport/TSocketClient.h +0 -32
  211. data/vendor/gems/thrift/lib/cocoa/src/transport/TSocketClient.m +0 -58
  212. data/vendor/gems/thrift/lib/cocoa/src/transport/TTransport.h +0 -36
  213. data/vendor/gems/thrift/lib/cocoa/src/transport/TTransportException.h +0 -30
  214. data/vendor/gems/thrift/lib/cocoa/src/transport/TTransportException.m +0 -43
  215. data/vendor/gems/thrift/lib/cpp/Makefile.am +0 -158
  216. data/vendor/gems/thrift/lib/cpp/README +0 -67
  217. data/vendor/gems/thrift/lib/cpp/src/TLogging.h +0 -163
  218. data/vendor/gems/thrift/lib/cpp/src/TProcessor.h +0 -53
  219. data/vendor/gems/thrift/lib/cpp/src/TReflectionLocal.h +0 -96
  220. data/vendor/gems/thrift/lib/cpp/src/Thrift.cpp +0 -148
  221. data/vendor/gems/thrift/lib/cpp/src/Thrift.h +0 -191
  222. data/vendor/gems/thrift/lib/cpp/src/concurrency/Exception.h +0 -60
  223. data/vendor/gems/thrift/lib/cpp/src/concurrency/FunctionRunner.h +0 -77
  224. data/vendor/gems/thrift/lib/cpp/src/concurrency/Monitor.cpp +0 -137
  225. data/vendor/gems/thrift/lib/cpp/src/concurrency/Monitor.h +0 -84
  226. data/vendor/gems/thrift/lib/cpp/src/concurrency/Mutex.cpp +0 -160
  227. data/vendor/gems/thrift/lib/cpp/src/concurrency/Mutex.h +0 -114
  228. data/vendor/gems/thrift/lib/cpp/src/concurrency/PosixThreadFactory.cpp +0 -314
  229. data/vendor/gems/thrift/lib/cpp/src/concurrency/PosixThreadFactory.h +0 -130
  230. data/vendor/gems/thrift/lib/cpp/src/concurrency/Thread.h +0 -125
  231. data/vendor/gems/thrift/lib/cpp/src/concurrency/ThreadManager.cpp +0 -493
  232. data/vendor/gems/thrift/lib/cpp/src/concurrency/ThreadManager.h +0 -169
  233. data/vendor/gems/thrift/lib/cpp/src/concurrency/TimerManager.cpp +0 -284
  234. data/vendor/gems/thrift/lib/cpp/src/concurrency/TimerManager.h +0 -122
  235. data/vendor/gems/thrift/lib/cpp/src/concurrency/Util.cpp +0 -55
  236. data/vendor/gems/thrift/lib/cpp/src/concurrency/Util.h +0 -100
  237. data/vendor/gems/thrift/lib/cpp/src/concurrency/test/Tests.cpp +0 -155
  238. data/vendor/gems/thrift/lib/cpp/src/concurrency/test/ThreadFactoryTests.h +0 -354
  239. data/vendor/gems/thrift/lib/cpp/src/concurrency/test/ThreadManagerTests.h +0 -379
  240. data/vendor/gems/thrift/lib/cpp/src/concurrency/test/TimerManagerTests.h +0 -155
  241. data/vendor/gems/thrift/lib/cpp/src/processor/PeekProcessor.cpp +0 -122
  242. data/vendor/gems/thrift/lib/cpp/src/processor/PeekProcessor.h +0 -77
  243. data/vendor/gems/thrift/lib/cpp/src/processor/StatsProcessor.h +0 -264
  244. data/vendor/gems/thrift/lib/cpp/src/protocol/TBase64Utils.cpp +0 -79
  245. data/vendor/gems/thrift/lib/cpp/src/protocol/TBase64Utils.h +0 -42
  246. data/vendor/gems/thrift/lib/cpp/src/protocol/TBinaryProtocol.cpp +0 -394
  247. data/vendor/gems/thrift/lib/cpp/src/protocol/TBinaryProtocol.h +0 -254
  248. data/vendor/gems/thrift/lib/cpp/src/protocol/TCompactProtocol.cpp +0 -736
  249. data/vendor/gems/thrift/lib/cpp/src/protocol/TCompactProtocol.h +0 -279
  250. data/vendor/gems/thrift/lib/cpp/src/protocol/TDebugProtocol.cpp +0 -346
  251. data/vendor/gems/thrift/lib/cpp/src/protocol/TDebugProtocol.h +0 -225
  252. data/vendor/gems/thrift/lib/cpp/src/protocol/TDenseProtocol.cpp +0 -762
  253. data/vendor/gems/thrift/lib/cpp/src/protocol/TDenseProtocol.h +0 -253
  254. data/vendor/gems/thrift/lib/cpp/src/protocol/TJSONProtocol.cpp +0 -998
  255. data/vendor/gems/thrift/lib/cpp/src/protocol/TJSONProtocol.h +0 -340
  256. data/vendor/gems/thrift/lib/cpp/src/protocol/TOneWayProtocol.h +0 -304
  257. data/vendor/gems/thrift/lib/cpp/src/protocol/TProtocol.h +0 -438
  258. data/vendor/gems/thrift/lib/cpp/src/protocol/TProtocolException.h +0 -104
  259. data/vendor/gems/thrift/lib/cpp/src/protocol/TProtocolTap.h +0 -187
  260. data/vendor/gems/thrift/lib/cpp/src/server/TNonblockingServer.cpp +0 -750
  261. data/vendor/gems/thrift/lib/cpp/src/server/TNonblockingServer.h +0 -435
  262. data/vendor/gems/thrift/lib/cpp/src/server/TServer.cpp +0 -38
  263. data/vendor/gems/thrift/lib/cpp/src/server/TServer.h +0 -213
  264. data/vendor/gems/thrift/lib/cpp/src/server/TSimpleServer.cpp +0 -118
  265. data/vendor/gems/thrift/lib/cpp/src/server/TSimpleServer.h +0 -70
  266. data/vendor/gems/thrift/lib/cpp/src/server/TThreadPoolServer.cpp +0 -217
  267. data/vendor/gems/thrift/lib/cpp/src/server/TThreadPoolServer.h +0 -79
  268. data/vendor/gems/thrift/lib/cpp/src/server/TThreadedServer.cpp +0 -243
  269. data/vendor/gems/thrift/lib/cpp/src/server/TThreadedServer.h +0 -74
  270. data/vendor/gems/thrift/lib/cpp/src/transport/TBufferTransports.cpp +0 -370
  271. data/vendor/gems/thrift/lib/cpp/src/transport/TBufferTransports.h +0 -667
  272. data/vendor/gems/thrift/lib/cpp/src/transport/TFDTransport.cpp +0 -77
  273. data/vendor/gems/thrift/lib/cpp/src/transport/TFDTransport.h +0 -73
  274. data/vendor/gems/thrift/lib/cpp/src/transport/TFileTransport.cpp +0 -953
  275. data/vendor/gems/thrift/lib/cpp/src/transport/TFileTransport.h +0 -442
  276. data/vendor/gems/thrift/lib/cpp/src/transport/THttpClient.cpp +0 -348
  277. data/vendor/gems/thrift/lib/cpp/src/transport/THttpClient.h +0 -111
  278. data/vendor/gems/thrift/lib/cpp/src/transport/TServerSocket.cpp +0 -368
  279. data/vendor/gems/thrift/lib/cpp/src/transport/TServerSocket.h +0 -76
  280. data/vendor/gems/thrift/lib/cpp/src/transport/TServerTransport.h +0 -92
  281. data/vendor/gems/thrift/lib/cpp/src/transport/TShortReadTransport.h +0 -96
  282. data/vendor/gems/thrift/lib/cpp/src/transport/TSimpleFileTransport.cpp +0 -54
  283. data/vendor/gems/thrift/lib/cpp/src/transport/TSimpleFileTransport.h +0 -41
  284. data/vendor/gems/thrift/lib/cpp/src/transport/TSocket.cpp +0 -591
  285. data/vendor/gems/thrift/lib/cpp/src/transport/TSocket.h +0 -242
  286. data/vendor/gems/thrift/lib/cpp/src/transport/TSocketPool.cpp +0 -235
  287. data/vendor/gems/thrift/lib/cpp/src/transport/TSocketPool.h +0 -191
  288. data/vendor/gems/thrift/lib/cpp/src/transport/TTransport.h +0 -224
  289. data/vendor/gems/thrift/lib/cpp/src/transport/TTransportException.cpp +0 -31
  290. data/vendor/gems/thrift/lib/cpp/src/transport/TTransportException.h +0 -117
  291. data/vendor/gems/thrift/lib/cpp/src/transport/TTransportUtils.cpp +0 -178
  292. data/vendor/gems/thrift/lib/cpp/src/transport/TTransportUtils.h +0 -287
  293. data/vendor/gems/thrift/lib/cpp/src/transport/TZlibTransport.cpp +0 -299
  294. data/vendor/gems/thrift/lib/cpp/src/transport/TZlibTransport.h +0 -219
  295. data/vendor/gems/thrift/lib/cpp/thrift-nb.pc.in +0 -30
  296. data/vendor/gems/thrift/lib/cpp/thrift-z.pc.in +0 -30
  297. data/vendor/gems/thrift/lib/cpp/thrift.pc.in +0 -29
  298. data/vendor/gems/thrift/lib/csharp/Makefile.am +0 -70
  299. data/vendor/gems/thrift/lib/csharp/README +0 -26
  300. data/vendor/gems/thrift/lib/csharp/ThriftMSBuildTask/Properties/AssemblyInfo.cs +0 -55
  301. data/vendor/gems/thrift/lib/csharp/ThriftMSBuildTask/ThriftBuild.cs +0 -242
  302. data/vendor/gems/thrift/lib/csharp/ThriftMSBuildTask/ThriftMSBuildTask.csproj +0 -62
  303. data/vendor/gems/thrift/lib/csharp/src/Collections/THashSet.cs +0 -142
  304. data/vendor/gems/thrift/lib/csharp/src/Protocol/TBase.cs +0 -34
  305. data/vendor/gems/thrift/lib/csharp/src/Protocol/TBinaryProtocol.cs +0 -392
  306. data/vendor/gems/thrift/lib/csharp/src/Protocol/TField.cs +0 -58
  307. data/vendor/gems/thrift/lib/csharp/src/Protocol/TList.cs +0 -50
  308. data/vendor/gems/thrift/lib/csharp/src/Protocol/TMap.cs +0 -58
  309. data/vendor/gems/thrift/lib/csharp/src/Protocol/TMessage.cs +0 -58
  310. data/vendor/gems/thrift/lib/csharp/src/Protocol/TProtocol.cs +0 -87
  311. data/vendor/gems/thrift/lib/csharp/src/Protocol/TProtocolException.cs +0 -61
  312. data/vendor/gems/thrift/lib/csharp/src/Protocol/TProtocolFactory.cs +0 -29
  313. data/vendor/gems/thrift/lib/csharp/src/Protocol/TProtocolUtil.cs +0 -94
  314. data/vendor/gems/thrift/lib/csharp/src/Protocol/TSet.cs +0 -50
  315. data/vendor/gems/thrift/lib/csharp/src/Protocol/TStruct.cs +0 -42
  316. data/vendor/gems/thrift/lib/csharp/src/Protocol/TType.cs +0 -40
  317. data/vendor/gems/thrift/lib/csharp/src/Server/TServer.cs +0 -135
  318. data/vendor/gems/thrift/lib/csharp/src/Server/TSimpleServer.cs +0 -148
  319. data/vendor/gems/thrift/lib/csharp/src/Server/TThreadPoolServer.cs +0 -186
  320. data/vendor/gems/thrift/lib/csharp/src/Server/TThreadedServer.cs +0 -234
  321. data/vendor/gems/thrift/lib/csharp/src/TApplicationException.cs +0 -131
  322. data/vendor/gems/thrift/lib/csharp/src/Thrift.csproj +0 -73
  323. data/vendor/gems/thrift/lib/csharp/src/Thrift.sln +0 -35
  324. data/vendor/gems/thrift/lib/csharp/src/Transport/TBufferedTransport.cs +0 -100
  325. data/vendor/gems/thrift/lib/csharp/src/Transport/TServerSocket.cs +0 -157
  326. data/vendor/gems/thrift/lib/csharp/src/Transport/TServerTransport.cs +0 -39
  327. data/vendor/gems/thrift/lib/csharp/src/Transport/TSocket.cs +0 -144
  328. data/vendor/gems/thrift/lib/csharp/src/Transport/TStreamTransport.cs +0 -103
  329. data/vendor/gems/thrift/lib/csharp/src/Transport/TTransport.cs +0 -66
  330. data/vendor/gems/thrift/lib/csharp/src/Transport/TTransportException.cs +0 -64
  331. data/vendor/gems/thrift/lib/csharp/src/Transport/TTransportFactory.cs +0 -38
  332. data/vendor/gems/thrift/lib/erl/README +0 -56
  333. data/vendor/gems/thrift/lib/erl/build/beamver +0 -59
  334. data/vendor/gems/thrift/lib/erl/build/buildtargets.mk +0 -15
  335. data/vendor/gems/thrift/lib/erl/build/colors.mk +0 -24
  336. data/vendor/gems/thrift/lib/erl/build/docs.mk +0 -12
  337. data/vendor/gems/thrift/lib/erl/build/mime.types +0 -98
  338. data/vendor/gems/thrift/lib/erl/build/otp.mk +0 -146
  339. data/vendor/gems/thrift/lib/erl/build/otp_subdir.mk +0 -85
  340. data/vendor/gems/thrift/lib/erl/build/raw_test.mk +0 -29
  341. data/vendor/gems/thrift/lib/erl/include/thrift_constants.hrl +0 -54
  342. data/vendor/gems/thrift/lib/erl/include/thrift_protocol.hrl +0 -31
  343. data/vendor/gems/thrift/lib/erl/src/Makefile +0 -116
  344. data/vendor/gems/thrift/lib/erl/src/test_handler.erl +0 -26
  345. data/vendor/gems/thrift/lib/erl/src/test_service.erl +0 -29
  346. data/vendor/gems/thrift/lib/erl/src/thrift.app.src +0 -44
  347. data/vendor/gems/thrift/lib/erl/src/thrift.appup.src +0 -1
  348. data/vendor/gems/thrift/lib/erl/src/thrift_base64_transport.erl +0 -64
  349. data/vendor/gems/thrift/lib/erl/src/thrift_binary_protocol.erl +0 -325
  350. data/vendor/gems/thrift/lib/erl/src/thrift_buffered_transport.erl +0 -180
  351. data/vendor/gems/thrift/lib/erl/src/thrift_client.erl +0 -384
  352. data/vendor/gems/thrift/lib/erl/src/thrift_disk_log_transport.erl +0 -118
  353. data/vendor/gems/thrift/lib/erl/src/thrift_file_transport.erl +0 -87
  354. data/vendor/gems/thrift/lib/erl/src/thrift_framed_transport.erl +0 -208
  355. data/vendor/gems/thrift/lib/erl/src/thrift_http_transport.erl +0 -199
  356. data/vendor/gems/thrift/lib/erl/src/thrift_memory_buffer.erl +0 -164
  357. data/vendor/gems/thrift/lib/erl/src/thrift_processor.erl +0 -188
  358. data/vendor/gems/thrift/lib/erl/src/thrift_protocol.erl +0 -356
  359. data/vendor/gems/thrift/lib/erl/src/thrift_server.erl +0 -183
  360. data/vendor/gems/thrift/lib/erl/src/thrift_service.erl +0 -25
  361. data/vendor/gems/thrift/lib/erl/src/thrift_socket_server.erl +0 -249
  362. data/vendor/gems/thrift/lib/erl/src/thrift_socket_transport.erl +0 -119
  363. data/vendor/gems/thrift/lib/erl/src/thrift_transport.erl +0 -57
  364. data/vendor/gems/thrift/lib/erl/vsn.mk +0 -1
  365. data/vendor/gems/thrift/lib/hs/README +0 -82
  366. data/vendor/gems/thrift/lib/hs/TODO +0 -2
  367. data/vendor/gems/thrift/lib/hs/Thrift.cabal +0 -20
  368. data/vendor/gems/thrift/lib/hs/src/Thrift/Protocol/Binary.hs +0 -147
  369. data/vendor/gems/thrift/lib/hs/src/Thrift/Protocol.hs +0 -191
  370. data/vendor/gems/thrift/lib/hs/src/Thrift/Server.hs +0 -65
  371. data/vendor/gems/thrift/lib/hs/src/Thrift/Transport/Handle.hs +0 -58
  372. data/vendor/gems/thrift/lib/hs/src/Thrift/Transport.hs +0 -60
  373. data/vendor/gems/thrift/lib/hs/src/Thrift.hs +0 -111
  374. data/vendor/gems/thrift/lib/java/README +0 -43
  375. data/vendor/gems/thrift/lib/java/build.xml +0 -195
  376. data/vendor/gems/thrift/lib/java/ivy.xml +0 -8
  377. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/IntRangeSet.java +0 -171
  378. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TApplicationException.java +0 -123
  379. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TBase.java +0 -66
  380. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TBaseHelper.java +0 -102
  381. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TByteArrayOutputStream.java +0 -46
  382. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TDeserializer.java +0 -94
  383. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TException.java +0 -45
  384. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TFieldRequirementType.java +0 -30
  385. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TProcessor.java +0 -32
  386. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TProcessorFactory.java +0 -39
  387. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TSerializer.java +0 -110
  388. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/meta_data/FieldMetaData.java +0 -69
  389. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/meta_data/FieldValueMetaData.java +0 -42
  390. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/meta_data/ListMetaData.java +0 -29
  391. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/meta_data/MapMetaData.java +0 -31
  392. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/meta_data/SetMetaData.java +0 -29
  393. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/meta_data/StructMetaData.java +0 -31
  394. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TBase64Utils.java +0 -128
  395. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TBinaryProtocol.java +0 -331
  396. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TCompactProtocol.java +0 -741
  397. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TField.java +0 -48
  398. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TJSONProtocol.java +0 -927
  399. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TList.java +0 -38
  400. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TMap.java +0 -40
  401. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TMessage.java +0 -48
  402. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TMessageType.java +0 -31
  403. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TProtocol.java +0 -146
  404. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TProtocolException.java +0 -81
  405. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TProtocolFactory.java +0 -30
  406. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TProtocolUtil.java +0 -158
  407. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TSet.java +0 -42
  408. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TSimpleJSONProtocol.java +0 -384
  409. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TStruct.java +0 -36
  410. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TType.java +0 -40
  411. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/server/THsHaServer.java +0 -304
  412. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/server/TNonblockingServer.java +0 -772
  413. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/server/TServer.java +0 -126
  414. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/server/TSimpleServer.java +0 -145
  415. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java +0 -271
  416. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TFramedTransport.java +0 -126
  417. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/THttpClient.java +0 -157
  418. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TIOStreamTransport.java +0 -159
  419. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TMemoryBuffer.java +0 -98
  420. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TNonblockingServerSocket.java +0 -160
  421. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TNonblockingServerTransport.java +0 -31
  422. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TNonblockingSocket.java +0 -213
  423. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TNonblockingTransport.java +0 -31
  424. data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TServerSocket.java +0 -145
@@ -1,1445 +0,0 @@
1
- /*
2
- * Licensed to the Apache Software Foundation (ASF) under one
3
- * or more contributor license agreements. See the NOTICE file
4
- * distributed with this work for additional information
5
- * regarding copyright ownership. The ASF licenses this file
6
- * to you under the Apache License, Version 2.0 (the
7
- * "License"); you may not use this file except in compliance
8
- * with the License. You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing,
13
- * software distributed under the License is distributed on an
14
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
- * KIND, either express or implied. See the License for the
16
- * specific language governing permissions and limitations
17
- * under the License.
18
- */
19
-
20
- #include <string>
21
- #include <fstream>
22
- #include <iostream>
23
- #include <vector>
24
-
25
- #include <stdlib.h>
26
- #include <sys/stat.h>
27
- #include <sys/types.h>
28
- #include <sstream>
29
- #include "t_oop_generator.h"
30
- #include "platform.h"
31
- using namespace std;
32
-
33
-
34
- /**
35
- * Haskell code generator.
36
- *
37
- */
38
- class t_hs_generator : public t_oop_generator {
39
- public:
40
- t_hs_generator(
41
- t_program* program,
42
- const std::map<std::string, std::string>& parsed_options,
43
- const std::string& option_string)
44
- : t_oop_generator(program)
45
- {
46
- out_dir_base_ = "gen-hs";
47
- }
48
-
49
- /**
50
- * Init and close methods
51
- */
52
-
53
- void init_generator();
54
- void close_generator();
55
-
56
- /**
57
- * Program-level generation functions
58
- */
59
- void generate_typedef (t_typedef* ttypedef);
60
- void generate_enum (t_enum* tenum);
61
- void generate_const (t_const* tconst);
62
- void generate_struct (t_struct* tstruct);
63
- void generate_xception (t_struct* txception);
64
- void generate_service (t_service* tservice);
65
-
66
- std::string render_const_value(t_type* type, t_const_value* value);
67
-
68
- /**
69
- * Struct generation code
70
- */
71
-
72
- void generate_hs_struct(t_struct* tstruct, bool is_exception);
73
- void generate_hs_struct_definition(std::ofstream &out,t_struct* tstruct, bool is_xception=false,bool helper=false);
74
- void generate_hs_struct_reader(std::ofstream& out, t_struct* tstruct);
75
- void generate_hs_struct_writer(std::ofstream& out, t_struct* tstruct);
76
- void generate_hs_function_helpers(t_function* tfunction);
77
-
78
- /**
79
- * Service-level generation functions
80
- */
81
-
82
- void generate_service_helpers (t_service* tservice);
83
- void generate_service_interface (t_service* tservice);
84
- void generate_service_client (t_service* tservice);
85
- void generate_service_server (t_service* tservice);
86
- void generate_process_function (t_service* tservice, t_function* tfunction);
87
-
88
- /**
89
- * Serialization constructs
90
- */
91
-
92
- void generate_deserialize_field (std::ofstream &out,
93
- t_field* tfield,
94
- std::string prefix);
95
-
96
- void generate_deserialize_struct (std::ofstream &out,
97
- t_struct* tstruct);
98
-
99
- void generate_deserialize_container (std::ofstream &out,
100
- t_type* ttype);
101
-
102
- void generate_deserialize_set_element (std::ofstream &out,
103
- t_set* tset);
104
-
105
-
106
- void generate_deserialize_list_element (std::ofstream &out,
107
- t_list* tlist,
108
- std::string prefix="");
109
- void generate_deserialize_type (std::ofstream &out,
110
- t_type* type);
111
-
112
- void generate_serialize_field (std::ofstream &out,
113
- t_field* tfield,
114
- std::string name= "");
115
-
116
- void generate_serialize_struct (std::ofstream &out,
117
- t_struct* tstruct,
118
- std::string prefix="");
119
-
120
- void generate_serialize_container (std::ofstream &out,
121
- t_type* ttype,
122
- std::string prefix="");
123
-
124
- void generate_serialize_map_element (std::ofstream &out,
125
- t_map* tmap,
126
- std::string kiter,
127
- std::string viter);
128
-
129
- void generate_serialize_set_element (std::ofstream &out,
130
- t_set* tmap,
131
- std::string iter);
132
-
133
- void generate_serialize_list_element (std::ofstream &out,
134
- t_list* tlist,
135
- std::string iter);
136
-
137
- /**
138
- * Helper rendering functions
139
- */
140
-
141
- std::string hs_autogen_comment();
142
- std::string hs_imports();
143
- std::string type_name(t_type* ttype);
144
- std::string function_type(t_function* tfunc, bool options = false, bool io = false, bool method = false);
145
- std::string type_to_enum(t_type* ttype);
146
- std::string render_hs_type(t_type* type, bool needs_parens = true);
147
-
148
-
149
- private:
150
-
151
- /**
152
- * File streams
153
- */
154
-
155
- std::ofstream f_types_;
156
- std::ofstream f_consts_;
157
- std::ofstream f_service_;
158
- std::ofstream f_iface_;
159
- std::ofstream f_client_;
160
-
161
- };
162
-
163
-
164
- /**
165
- * Prepares for file generation by opening up the necessary file output
166
- * streams.
167
- *
168
- * @param tprogram The program to generate
169
- */
170
- void t_hs_generator::init_generator() {
171
- // Make output directory
172
- MKDIR(get_out_dir().c_str());
173
-
174
- // Make output file
175
-
176
- string pname = capitalize(program_name_);
177
- string f_types_name = get_out_dir()+pname+"_Types.hs";
178
- f_types_.open(f_types_name.c_str());
179
-
180
- string f_consts_name = get_out_dir()+pname+"_Consts.hs";
181
- f_consts_.open(f_consts_name.c_str());
182
-
183
- // Print header
184
- f_types_ <<
185
- hs_autogen_comment() << endl <<
186
- "module " << pname <<"_Types where" << endl <<
187
- hs_imports() << endl;
188
-
189
- f_consts_ <<
190
- hs_autogen_comment() << endl <<
191
- "module " << pname <<"_Consts where" << endl <<
192
- hs_imports() << endl <<
193
- "import " << pname<<"_Types"<< endl;
194
-
195
- }
196
-
197
-
198
- /**
199
- * Autogen'd comment
200
- */
201
- string t_hs_generator::hs_autogen_comment() {
202
- return
203
- std::string("-----------------------------------------------------------------\n") +
204
- "-- Autogenerated by Thrift --\n" +
205
- "-- --\n" +
206
- "-- DO NOT EDIT UNLESS YOU ARE SURE YOU KNOW WHAT YOU ARE DOING --\n" +
207
- "-----------------------------------------------------------------\n";
208
- }
209
-
210
- /**
211
- * Prints standard thrift imports
212
- */
213
- string t_hs_generator::hs_imports() {
214
- return "import Thrift\nimport Data.Typeable ( Typeable )\nimport Control.Exception\nimport qualified Data.Map as Map\nimport qualified Data.Set as Set\nimport Data.Int";
215
- }
216
-
217
- /**
218
- * Closes the type files
219
- */
220
- void t_hs_generator::close_generator() {
221
- // Close types file
222
- f_types_.close();
223
- f_consts_.close();
224
- }
225
-
226
- /**
227
- * Generates a typedef. Ez.
228
- *
229
- * @param ttypedef The type definition
230
- */
231
- void t_hs_generator::generate_typedef(t_typedef* ttypedef) {
232
- f_types_ <<
233
- indent() << "type "<< capitalize(ttypedef->get_symbolic()) << " = " << render_hs_type(ttypedef->get_type(), false) << endl << endl;
234
- }
235
-
236
- /**
237
- * Generates code for an enumerated type.
238
- * the values.
239
- *
240
- * @param tenum The enumeration
241
- */
242
- void t_hs_generator::generate_enum(t_enum* tenum) {
243
- indent(f_types_) << "data "<<capitalize(tenum->get_name())<<" = ";
244
- indent_up();
245
- vector<t_enum_value*> constants = tenum->get_constants();
246
- vector<t_enum_value*>::iterator c_iter;
247
- bool first = true;
248
- for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
249
- string name = capitalize((*c_iter)->get_name());
250
- if(first)
251
- first=false;
252
- else
253
- f_types_ << "|";
254
- f_types_ << name;
255
- }
256
- indent(f_types_) << "deriving (Show,Eq, Typeable, Ord)" << endl;
257
- indent_down();
258
-
259
- int value = -1;
260
- indent(f_types_) << "instance Enum " << capitalize(tenum->get_name()) << " where" << endl;
261
- indent_up();
262
- indent(f_types_) << "fromEnum t = case t of" << endl;
263
- indent_up();
264
- for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
265
- if ((*c_iter)->has_value()) {
266
- value = (*c_iter)->get_value();
267
- } else {
268
- ++value;
269
- }
270
- string name = capitalize((*c_iter)->get_name());
271
-
272
- f_types_ <<
273
- indent() << name << " -> " << value << endl;
274
- }
275
- indent_down();
276
-
277
- indent(f_types_) << "toEnum t = case t of" << endl;
278
- indent_up();
279
- for(c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
280
- if ((*c_iter)->has_value()) {
281
- value = (*c_iter)->get_value();
282
- } else {
283
- ++value;
284
- }
285
- string name = capitalize((*c_iter)->get_name());
286
-
287
- f_types_ <<
288
- indent() << value << " -> " << name << endl;
289
- }
290
- indent(f_types_) << "_ -> throw ThriftException" << endl;
291
- indent_down();
292
- indent_down();
293
- }
294
-
295
- /**
296
- * Generate a constant value
297
- */
298
- void t_hs_generator::generate_const(t_const* tconst) {
299
- t_type* type = tconst->get_type();
300
- string name = decapitalize(tconst->get_name());
301
- t_const_value* value = tconst->get_value();
302
-
303
- indent(f_consts_) << name << " :: " << render_hs_type(type, false) << endl;
304
- indent(f_consts_) << name << " = " << render_const_value(type, value) << endl << endl;
305
- }
306
-
307
- /**
308
- * Prints the value of a constant with the given type. Note that type checking
309
- * is NOT performed in this function as it is always run beforehand using the
310
- * validate_types method in main.cc
311
- */
312
- string t_hs_generator::render_const_value(t_type* type, t_const_value* value) {
313
- type = get_true_type(type);
314
- std::ostringstream out;
315
- if (type->is_base_type()) {
316
- t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
317
- switch (tbase) {
318
- case t_base_type::TYPE_STRING:
319
- out << '"' << get_escaped_string(value) << '"';
320
- break;
321
- case t_base_type::TYPE_BOOL:
322
- out << (value->get_integer() > 0 ? "True" : "False");
323
- break;
324
- case t_base_type::TYPE_BYTE:
325
- case t_base_type::TYPE_I16:
326
- case t_base_type::TYPE_I32:
327
- case t_base_type::TYPE_I64:
328
- out << value->get_integer();
329
- break;
330
- case t_base_type::TYPE_DOUBLE:
331
- if (value->get_type() == t_const_value::CV_INTEGER) {
332
- out << value->get_integer();
333
- } else {
334
- out << value->get_double();
335
- }
336
- break;
337
- default:
338
- throw "compiler error: no const of base type " + t_base_type::t_base_name(tbase);
339
- }
340
- } else if (type->is_enum()) {
341
- t_enum* tenum = (t_enum*)type;
342
- vector<t_enum_value*> constants = tenum->get_constants();
343
- vector<t_enum_value*>::iterator c_iter;
344
- int val = -1;
345
- for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
346
- if ((*c_iter)->has_value()) {
347
- val = (*c_iter)->get_value();
348
- } else {
349
- ++val;
350
- }
351
- if(val == value->get_integer()){
352
- indent(out) << capitalize((*c_iter)->get_name());
353
- break;
354
- }
355
- }
356
- } else if (type->is_struct() || type->is_xception()) {
357
- string cname = type_name(type);
358
- indent(out) << cname << "{";
359
- const vector<t_field*>& fields = ((t_struct*)type)->get_members();
360
- vector<t_field*>::const_iterator f_iter;
361
- const map<t_const_value*, t_const_value*>& val = value->get_map();
362
- map<t_const_value*, t_const_value*>::const_iterator v_iter;
363
- bool first = true;
364
- for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
365
- t_type* field_type = NULL;
366
- for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
367
- if ((*f_iter)->get_name() == v_iter->first->get_string()) {
368
- field_type = (*f_iter)->get_type();
369
- }
370
- }
371
- if (field_type == NULL) {
372
- throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
373
- }
374
- string fname = v_iter->first->get_string();
375
- if(first)
376
- first=false;
377
- else
378
- out << ",";
379
- out << "f_" << cname << "_" << fname << " = Just (" << render_const_value(field_type, v_iter->second) << ")";
380
-
381
- }
382
- indent(out) << "}";
383
- } else if (type->is_map()) {
384
- t_type* ktype = ((t_map*)type)->get_key_type();
385
- t_type* vtype = ((t_map*)type)->get_val_type();
386
- const map<t_const_value*, t_const_value*>& val = value->get_map();
387
- map<t_const_value*, t_const_value*>::const_iterator v_iter;
388
- out << "(Map.fromList [";
389
- bool first=true;
390
- for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
391
- string key = render_const_value(ktype, v_iter->first);
392
- string val = render_const_value(vtype, v_iter->second);
393
- if(first)
394
- first=false;
395
- else
396
- out << ",";
397
- out << "(" << key << ","<< val << ")";
398
- }
399
- out << "])";
400
- } else if (type->is_list() || type->is_set()) {
401
- t_type* etype;
402
-
403
- if (type->is_list()) {
404
- etype = ((t_list*) type)->get_elem_type();
405
- } else {
406
- etype = ((t_set*) type)->get_elem_type();
407
- }
408
-
409
- const vector<t_const_value*>& val = value->get_list();
410
- vector<t_const_value*>::const_iterator v_iter;
411
- bool first = true;
412
-
413
- if (type->is_set())
414
- out << "(Set.fromList ";
415
-
416
- out << "[";
417
-
418
- for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
419
- if(first)
420
- first=false;
421
- else
422
- out << ",";
423
- out << render_const_value(etype, *v_iter);
424
- }
425
-
426
- out << "]";
427
- if (type->is_set())
428
- out << ")";
429
- } else {
430
- throw "CANNOT GENERATE CONSTANT FOR TYPE: " + type->get_name();
431
- }
432
- return out.str();
433
- }
434
-
435
- /**
436
- * Generates a "struct"
437
- */
438
- void t_hs_generator::generate_struct(t_struct* tstruct) {
439
- generate_hs_struct(tstruct, false);
440
- }
441
-
442
- /**
443
- * Generates a struct definition for a thrift exception. Basically the same
444
- * as a struct, but also has an exception declaration.
445
- *
446
- * @param txception The struct definition
447
- */
448
- void t_hs_generator::generate_xception(t_struct* txception) {
449
- generate_hs_struct(txception, true);
450
- }
451
-
452
- /**
453
- * Generates a Haskell struct
454
- */
455
- void t_hs_generator::generate_hs_struct(t_struct* tstruct,
456
- bool is_exception) {
457
- generate_hs_struct_definition(f_types_,tstruct, is_exception,false);
458
- }
459
-
460
- /**
461
- * Generates a struct definition for a thrift data type.
462
- *
463
- * @param tstruct The struct definition
464
- */
465
- void t_hs_generator::generate_hs_struct_definition(ofstream& out,
466
- t_struct* tstruct,
467
- bool is_exception,
468
- bool helper) {
469
- string tname = type_name(tstruct);
470
- string name = tstruct->get_name();
471
- const vector<t_field*>& members = tstruct->get_members();
472
- vector<t_field*>::const_iterator m_iter;
473
-
474
- indent(out) << "data "<<tname<<" = "<<tname;
475
- if (members.size() > 0) {
476
- out << "{";
477
- bool first=true;
478
- for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
479
- if(first)
480
- first=false;
481
- else
482
- out << ",";
483
- string mname = (*m_iter)->get_name();
484
- out << "f_" << tname << "_" << mname << " :: Maybe " << render_hs_type((*m_iter)->get_type());
485
- }
486
- out << "}";
487
- }
488
-
489
- out << " deriving (Show,Eq,Ord,Typeable)" << endl;
490
- if (is_exception) out << "instance Exception " << tname << endl;
491
- generate_hs_struct_writer(out, tstruct);
492
-
493
- generate_hs_struct_reader(out, tstruct);
494
- //f_struct_.close();
495
- }
496
-
497
-
498
-
499
- /**
500
- * Generates the read method for a struct
501
- */
502
- void t_hs_generator::generate_hs_struct_reader(ofstream& out, t_struct* tstruct) {
503
- const vector<t_field*>& fields = tstruct->get_members();
504
- vector<t_field*>::const_iterator f_iter;
505
- string sname = type_name(tstruct);
506
- string str = tmp("_str");
507
- string t = tmp("_t");
508
- string id = tmp("_id");
509
-
510
- indent(out) << "read_" << sname << "_fields iprot rec = do" << endl;
511
- indent_up(); // do
512
-
513
- // Read beginning field marker
514
- indent(out) << "(_," << t <<","<<id<<") <- readFieldBegin iprot" << endl;
515
- // Check for field STOP marker and break
516
- indent(out) <<
517
- "if " << t <<" == T_STOP then return rec else" << endl;
518
- indent_up(); // if
519
- indent(out) << "case " << id<<" of " << endl;
520
- indent_up(); // case
521
- // Generate deserialization code for known cases
522
- for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
523
- indent(out) << (*f_iter)->get_key() << " -> ";
524
- out << "if " << t <<" == " << type_to_enum((*f_iter)->get_type()) << " then do" << endl;
525
- indent_up(); // if
526
- indent(out) << "s <- ";
527
- generate_deserialize_field(out, *f_iter,str);
528
- out << endl;
529
- indent(out) << "read_"<<sname<<"_fields iprot rec{f_"<<sname<<"_"<< decapitalize((*f_iter)->get_name()) <<"=Just s}" << endl;
530
- out <<
531
- indent() << "else do" << endl;
532
- indent_up();
533
- indent(out) << "skip iprot "<< t << endl;
534
- indent(out) << "read_"<<sname<<"_fields iprot rec" << endl;
535
- indent_down(); // -do
536
- indent_down(); // -if
537
- }
538
-
539
-
540
- // In the default case we skip the field
541
- out <<
542
- indent() << "_ -> do" << endl;
543
- indent_up();
544
- indent(out) << "skip iprot "<<t<< endl;
545
- indent(out) << "readFieldEnd iprot" << endl;
546
- indent(out) << "read_"<<sname<<"_fields iprot rec" << endl;
547
- indent_down(); // -case
548
- indent_down(); // -if
549
- indent_down(); // -do
550
- indent_down();
551
-
552
- // read
553
- indent(out) << "read_"<<sname<<" iprot = do" << endl;
554
- indent_up();
555
- indent(out) << "readStructBegin iprot" << endl;
556
- indent(out) << "rec <- read_"<<sname<<"_fields iprot ("<<sname<<"{";
557
- bool first = true;
558
- for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
559
- if(first)
560
- first=false;
561
- else
562
- out << ",";
563
- out << "f_" << sname << "_" << decapitalize((*f_iter)->get_name()) << "=Nothing";
564
- }
565
- out << "})" << endl;
566
- indent(out) << "readStructEnd iprot" << endl;
567
- indent(out) << "return rec" << endl;
568
- indent_down();
569
- }
570
-
571
- void t_hs_generator::generate_hs_struct_writer(ofstream& out,
572
- t_struct* tstruct) {
573
- string name = type_name(tstruct);
574
- const vector<t_field*>& fields = tstruct->get_sorted_members();
575
- vector<t_field*>::const_iterator f_iter;
576
- string str = tmp("_str");
577
- string f = tmp("_f");
578
-
579
- indent(out) <<
580
- "write_"<<name<<" oprot rec = do" << endl;
581
- indent_up();
582
- indent(out) <<
583
- "writeStructBegin oprot \""<<name<<"\"" << endl;
584
- for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
585
- // Write field header
586
- string mname = (*f_iter)->get_name();
587
- indent(out) <<
588
- "case f_" << name << "_" << mname << " rec of {Nothing -> return (); Just _v -> do" << endl;
589
- indent_up();
590
- indent(out) << "writeFieldBegin oprot (\""<< (*f_iter)->get_name()<<"\","
591
- <<type_to_enum((*f_iter)->get_type())<<","
592
- <<(*f_iter)->get_key()<<")" << endl;
593
-
594
- // Write field contents
595
- out << indent();
596
- generate_serialize_field(out, *f_iter, "_v");
597
- out << endl;
598
- // Write field closer
599
- indent(out) << "writeFieldEnd oprot}" << endl;
600
- indent_down();
601
- }
602
-
603
- // Write the struct map
604
- out <<
605
- indent() << "writeFieldStop oprot" << endl <<
606
- indent() << "writeStructEnd oprot" << endl;
607
-
608
- indent_down();
609
- }
610
-
611
- /**
612
- * Generates a thrift service.
613
- *
614
- * @param tservice The service definition
615
- */
616
- void t_hs_generator::generate_service(t_service* tservice) {
617
- string f_service_name = get_out_dir()+capitalize(service_name_)+".hs";
618
- f_service_.open(f_service_name.c_str());
619
-
620
- f_service_ <<
621
- hs_autogen_comment() << endl <<
622
- "module " << capitalize(service_name_) << " where" << endl <<
623
- hs_imports() << endl;
624
-
625
-
626
- if(tservice->get_extends()){
627
- f_service_ <<
628
- "import qualified " << capitalize(tservice->get_extends()->get_name()) << endl;
629
- }
630
-
631
-
632
- f_service_ <<
633
- "import " << capitalize(program_name_) << "_Types" << endl <<
634
- "import qualified " << capitalize(service_name_) << "_Iface as Iface" << endl;
635
-
636
-
637
- // Generate the three main parts of the service
638
- generate_service_helpers(tservice);
639
- generate_service_interface(tservice);
640
- generate_service_client(tservice);
641
- generate_service_server(tservice);
642
-
643
-
644
- // Close service file
645
- f_service_.close();
646
- }
647
-
648
- /**
649
- * Generates helper functions for a service.
650
- *
651
- * @param tservice The service to generate a header definition for
652
- */
653
- void t_hs_generator::generate_service_helpers(t_service* tservice) {
654
- vector<t_function*> functions = tservice->get_functions();
655
- vector<t_function*>::iterator f_iter;
656
-
657
- indent(f_service_) <<
658
- "-- HELPER FUNCTIONS AND STRUCTURES --" << endl << endl;
659
-
660
- for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
661
- t_struct* ts = (*f_iter)->get_arglist();
662
- generate_hs_struct_definition(f_service_,ts, false);
663
- generate_hs_function_helpers(*f_iter);
664
- }
665
- }
666
-
667
- /**
668
- * Generates a struct and helpers for a function.
669
- *
670
- * @param tfunction The function
671
- */
672
- void t_hs_generator::generate_hs_function_helpers(t_function* tfunction) {
673
- t_struct result(program_, decapitalize(tfunction->get_name()) + "_result");
674
- t_field success(tfunction->get_returntype(), "success", 0);
675
- if (!tfunction->get_returntype()->is_void()) {
676
- result.append(&success);
677
- }
678
-
679
- t_struct* xs = tfunction->get_xceptions();
680
- const vector<t_field*>& fields = xs->get_members();
681
- vector<t_field*>::const_iterator f_iter;
682
- for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
683
- result.append(*f_iter);
684
- }
685
- generate_hs_struct_definition(f_service_,&result, false);
686
- }
687
-
688
- /**
689
- * Generates a service interface definition.
690
- *
691
- * @param tservice The service to generate a header definition for
692
- */
693
- void t_hs_generator::generate_service_interface(t_service* tservice) {
694
- string f_iface_name = get_out_dir()+capitalize(service_name_)+"_Iface.hs";
695
- f_iface_.open(f_iface_name.c_str());
696
- indent(f_iface_) << "module " << capitalize(service_name_) << "_Iface where" << endl;
697
-
698
- indent(f_iface_) <<
699
- hs_imports() << endl <<
700
- "import " << capitalize(program_name_) << "_Types" << endl <<
701
- endl;
702
-
703
- if (tservice->get_extends() != NULL) {
704
- string extends = type_name(tservice->get_extends());
705
- indent(f_iface_) << "import " << extends <<"_Iface" << endl;
706
- indent(f_iface_) << "class "<< extends << "_Iface a => " << capitalize(service_name_) << "_Iface a where" << endl;
707
- } else {
708
- f_iface_ << indent() << "class " << capitalize(service_name_) << "_Iface a where" << endl;
709
- }
710
- indent_up();
711
-
712
- vector<t_function*> functions = tservice->get_functions();
713
- vector<t_function*>::iterator f_iter;
714
- for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
715
- string ft = function_type(*f_iter,true,true,true);
716
- f_iface_ <<
717
- indent() << decapitalize((*f_iter)->get_name()) << " :: a -> " << ft << endl;
718
- }
719
- indent_down();
720
- f_iface_.close();
721
-
722
- }
723
-
724
- /**
725
- * Generates a service client definition. Note that in Haskell, the client doesn't implement iface. This is because
726
- * The client does not (and should not have to) deal with arguments being Nothing.
727
- *
728
- * @param tservice The service to generate a server for.
729
- */
730
- void t_hs_generator::generate_service_client(t_service* tservice) {
731
- string f_client_name = get_out_dir()+capitalize(service_name_)+"_Client.hs";
732
- f_client_.open(f_client_name.c_str());
733
-
734
- vector<t_function*> functions = tservice->get_functions();
735
- vector<t_function*>::const_iterator f_iter;
736
-
737
- string extends = "";
738
- string exports="";
739
- bool first = true;
740
- for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
741
- if(first)
742
- first=false;
743
- else
744
- exports+=",";
745
- string funname = (*f_iter)->get_name();
746
- exports+=funname;
747
- }
748
- indent(f_client_) << "module " << capitalize(service_name_) << "_Client("<<exports<<") where" << endl;
749
-
750
- if (tservice->get_extends() != NULL) {
751
- extends = type_name(tservice->get_extends());
752
- indent(f_client_) << "import " << extends << "_Client" << endl;
753
- }
754
- indent(f_client_) << "import Data.IORef" << endl;
755
- indent(f_client_) << hs_imports() << endl;
756
- indent(f_client_) << "import " << capitalize(program_name_) << "_Types" << endl;
757
- indent(f_client_) << "import " << capitalize(service_name_) << endl;
758
- // DATS RITE A GLOBAL VAR
759
- indent(f_client_) << "seqid = newIORef 0" << endl;
760
-
761
-
762
- // Generate client method implementations
763
-
764
- for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
765
- t_struct* arg_struct = (*f_iter)->get_arglist();
766
- const vector<t_field*>& fields = arg_struct->get_members();
767
- vector<t_field*>::const_iterator fld_iter;
768
- string funname = (*f_iter)->get_name();
769
-
770
- string fargs = "";
771
- for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
772
- fargs+= " arg_" + decapitalize((*fld_iter)->get_name());
773
- }
774
-
775
- // Open function
776
- indent(f_client_) << funname << " (ip,op)" << fargs << " = do" << endl;
777
- indent_up();
778
- indent(f_client_) << "send_" << funname << " op" << fargs;
779
-
780
- f_client_ << endl;
781
-
782
- if (!(*f_iter)->is_oneway()) {
783
- f_client_ << indent();
784
- f_client_ <<
785
- "recv_" << funname << " ip" << endl;
786
- }
787
- indent_down();
788
-
789
- indent(f_client_) <<
790
- "send_" << funname << " op" << fargs << " = do" << endl;
791
- indent_up();
792
- indent(f_client_) << "seq <- seqid" << endl;
793
- indent(f_client_) << "seqn <- readIORef seq" << endl;
794
- std::string argsname = capitalize((*f_iter)->get_name() + "_args");
795
-
796
- // Serialize the request header
797
- f_client_ <<
798
- indent() << "writeMessageBegin op (\"" << (*f_iter)->get_name() << "\", M_CALL, seqn)" << endl;
799
- f_client_ << indent() << "write_" << argsname << " op ("<<argsname<<"{";
800
- bool first = true;
801
- for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
802
- if(first)
803
- first=false;
804
- else
805
- f_client_ << ",";
806
- f_client_ << "f_" << argsname <<"_" << (*fld_iter)->get_name() << "=Just arg_" << (*fld_iter)->get_name();
807
- }
808
- f_client_ << "})" << endl;
809
-
810
- // Write to the stream
811
- f_client_ <<
812
- indent() << "writeMessageEnd op" << endl <<
813
- indent() << "tFlush (getTransport op)" << endl;
814
-
815
- indent_down();
816
-
817
- if (!(*f_iter)->is_oneway()) {
818
- std::string resultname = capitalize((*f_iter)->get_name() + "_result");
819
- t_struct noargs(program_);
820
-
821
- std::string funname = string("recv_") + (*f_iter)->get_name();
822
-
823
- t_function recv_function((*f_iter)->get_returntype(),
824
- funname,
825
- &noargs);
826
- // Open function
827
- f_client_ <<
828
- indent() << funname << " ip = do" << endl;
829
- indent_up(); // fun
830
-
831
- // TODO(mcslee): Validate message reply here, seq ids etc.
832
-
833
- f_client_ <<
834
- indent() << "(fname, mtype, rseqid) <- readMessageBegin ip" << endl;
835
- f_client_ <<
836
- indent() << "if mtype == M_EXCEPTION then do" << endl <<
837
- indent() << " x <- readAppExn ip" << endl <<
838
- indent() << " readMessageEnd ip" << endl;
839
- f_client_ <<
840
- indent() << " throw x" << endl;
841
- f_client_ <<
842
- indent() << " else return ()" << endl;
843
-
844
- t_struct* xs = (*f_iter)->get_xceptions();
845
- const std::vector<t_field*>& xceptions = xs->get_members();
846
-
847
- f_client_ <<
848
- indent() << "res <- read_" << resultname << " ip" << endl;
849
- f_client_ <<
850
- indent() << "readMessageEnd ip" << endl;
851
-
852
- // Careful, only return _result if not a void function
853
- if (!(*f_iter)->get_returntype()->is_void()) {
854
- f_client_ <<
855
- indent() << "case f_" << resultname << "_success res of" << endl;
856
- indent_up(); // case
857
- indent(f_client_) << "Just v -> return v" << endl;
858
- indent(f_client_) << "Nothing -> do" << endl;
859
- indent_up(); // none
860
- }
861
-
862
-
863
- vector<t_field*>::const_iterator x_iter;
864
- for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
865
- f_client_ <<
866
- indent() << "case f_"<< resultname << "_" << (*x_iter)->get_name() << " res of" << endl;
867
- indent_up(); //case
868
- indent(f_client_) << "Nothing -> return ()" << endl;
869
- indent(f_client_) << "Just _v -> throw _v" << endl;
870
- indent_down(); //-case
871
- }
872
-
873
- // Careful, only return _result if not a void function
874
- if ((*f_iter)->get_returntype()->is_void()) {
875
- indent(f_client_) <<
876
- "return ()" << endl;
877
- } else {
878
- f_client_ <<
879
- indent() << "throw (AppExn AE_MISSING_RESULT \"" << (*f_iter)->get_name() << " failed: unknown result\")" << endl;
880
- indent_down(); //-none
881
- indent_down(); //-case
882
- }
883
-
884
- // Close function
885
- indent_down(); //-fun
886
- }
887
- }
888
- f_client_.close();
889
-
890
-
891
- }
892
-
893
- /**
894
- * Generates a service server definition.
895
- *
896
- * @param tservice The service to generate a server for.
897
- */
898
- void t_hs_generator::generate_service_server(t_service* tservice) {
899
- // Generate the dispatch methods
900
- vector<t_function*> functions = tservice->get_functions();
901
- vector<t_function*>::iterator f_iter;
902
-
903
- // Generate the process subfunctions
904
- for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
905
- generate_process_function(tservice, *f_iter);
906
- }
907
-
908
-
909
- indent(f_service_) << "proc handler (iprot,oprot) (name,typ,seqid) = case name of" << endl;
910
- indent_up();
911
- for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
912
- string fname = (*f_iter)->get_name();
913
- indent(f_service_) << "\""<<fname<<"\" -> process_" << decapitalize(fname) << " (seqid,iprot,oprot,handler)" << endl;
914
- }
915
- indent(f_service_) << "_ -> ";
916
- if(tservice->get_extends() != NULL){
917
- f_service_ << type_name(tservice->get_extends()) << ".proc handler (iprot,oprot) (name,typ,seqid)" << endl;
918
- } else {
919
- f_service_ << "do" << endl;
920
- indent_up();
921
- indent(f_service_) << "skip iprot T_STRUCT" << endl;
922
- indent(f_service_) << "readMessageEnd iprot" << endl;
923
- indent(f_service_) << "writeMessageBegin oprot (name,M_EXCEPTION,seqid)" << endl;
924
- indent(f_service_) << "writeAppExn oprot (AppExn AE_UNKNOWN_METHOD (\"Unknown function \" ++ name))" << endl;
925
- indent(f_service_) << "writeMessageEnd oprot" << endl;
926
- indent(f_service_) << "tFlush (getTransport oprot)" << endl;
927
- indent_down();
928
- }
929
- indent_down();
930
-
931
- // Generate the server implementation
932
- indent(f_service_) <<
933
- "process handler (iprot, oprot) = do" << endl;
934
- indent_up();
935
-
936
- f_service_ <<
937
- indent() << "(name, typ, seqid) <- readMessageBegin iprot" << endl;
938
- f_service_ << indent() << "proc handler (iprot,oprot) (name,typ,seqid)" << endl;
939
- indent(f_service_) << "return True" << endl;
940
- indent_down();
941
-
942
- }
943
-
944
- /**
945
- * Generates a process function definition.
946
- *
947
- * @param tfunction The function to write a dispatcher for
948
- */
949
- void t_hs_generator::generate_process_function(t_service* tservice,
950
- t_function* tfunction) {
951
- // Open function
952
- indent(f_service_) <<
953
- "process_" << tfunction->get_name() << " (seqid, iprot, oprot, handler) = do" << endl;
954
- indent_up();
955
-
956
- string argsname = capitalize(tfunction->get_name()) + "_args";
957
- string resultname = capitalize(tfunction->get_name()) + "_result";
958
-
959
- // Generate the function call
960
- t_struct* arg_struct = tfunction->get_arglist();
961
- const std::vector<t_field*>& fields = arg_struct->get_members();
962
- vector<t_field*>::const_iterator f_iter;
963
-
964
-
965
- f_service_ <<
966
- indent() << "args <- read_" << argsname << " iprot" << endl;
967
- f_service_ <<
968
- indent() << "readMessageEnd iprot" << endl;
969
-
970
- t_struct* xs = tfunction->get_xceptions();
971
- const std::vector<t_field*>& xceptions = xs->get_members();
972
- vector<t_field*>::const_iterator x_iter;
973
- int n = xceptions.size();
974
- if (!tfunction->is_oneway()){
975
- if(!tfunction->get_returntype()->is_void()){
976
- n++;
977
- }
978
- indent(f_service_) << "rs <- return (" << resultname;
979
-
980
- for(int i=0; i<n;i++){
981
- f_service_ << " Nothing";
982
- }
983
- f_service_ << ")" << endl;
984
- }
985
-
986
- indent(f_service_) << "res <- ";
987
- // Try block for a function with exceptions
988
- if (xceptions.size() > 0) {
989
- for(unsigned int i=0;i<xceptions.size();i++){
990
- f_service_ << "(Control.Exception.catch" << endl;
991
- indent_up();
992
- f_service_ << indent();
993
- }
994
- }
995
-
996
- f_service_ << "(do" << endl;
997
- indent_up();
998
- f_service_ << indent();
999
- if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()){
1000
- f_service_ << "res <- ";
1001
- }
1002
- f_service_ << "Iface." << tfunction->get_name() << " handler";
1003
- for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
1004
- f_service_ << " (f_" << argsname << "_" << (*f_iter)->get_name() << " args)";
1005
- }
1006
-
1007
-
1008
- if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()){
1009
- f_service_ << endl;
1010
- indent(f_service_) << "return rs{f_"<<resultname<<"_success= Just res}";
1011
- } else if (!tfunction->is_oneway()){
1012
- f_service_ << endl;
1013
- indent(f_service_) << "return rs";
1014
- }
1015
- f_service_ << ")" << endl;
1016
- indent_down();
1017
-
1018
- if (xceptions.size() > 0 && !tfunction->is_oneway()) {
1019
- for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
1020
- indent(f_service_) << "(\\e -> " <<endl;
1021
- indent_up();
1022
- if(!tfunction->is_oneway()){
1023
- f_service_ <<
1024
- indent() << "return rs{f_"<<resultname<<"_" << (*x_iter)->get_name() << " =Just e}";
1025
- } else {
1026
- indent(f_service_) << "return ()";
1027
- }
1028
- f_service_ << "))" << endl;
1029
- indent_down();
1030
- indent_down();
1031
- }
1032
- }
1033
-
1034
-
1035
-
1036
- // Shortcut out here for oneway functions
1037
- if (tfunction->is_oneway()) {
1038
- f_service_ <<
1039
- indent() << "return ()" << endl;
1040
- indent_down();
1041
- return;
1042
- }
1043
-
1044
- f_service_ <<
1045
- indent() << "writeMessageBegin oprot (\"" << tfunction->get_name() << "\", M_REPLY, seqid);" << endl <<
1046
- indent() << "write_"<<resultname<<" oprot res" << endl <<
1047
- indent() << "writeMessageEnd oprot" << endl <<
1048
- indent() << "tFlush (getTransport oprot)" << endl;
1049
-
1050
- // Close function
1051
- indent_down();
1052
- }
1053
-
1054
- /**
1055
- * Deserializes a field of any type.
1056
- */
1057
- void t_hs_generator::generate_deserialize_field(ofstream &out,
1058
- t_field* tfield,
1059
- string prefix){
1060
- t_type* type = tfield->get_type();
1061
- generate_deserialize_type(out,type);
1062
- }
1063
-
1064
-
1065
- /**
1066
- * Deserializes a field of any type.
1067
- */
1068
- void t_hs_generator::generate_deserialize_type(ofstream &out,
1069
- t_type* type){
1070
- type = get_true_type(type);
1071
-
1072
- if (type->is_void()) {
1073
- throw "CANNOT GENERATE DESERIALIZE CODE FOR void TYPE";
1074
- }
1075
-
1076
-
1077
- if (type->is_struct() || type->is_xception()) {
1078
- generate_deserialize_struct(out,
1079
- (t_struct*)type);
1080
- } else if (type->is_container()) {
1081
- generate_deserialize_container(out, type);
1082
- } else if (type->is_base_type()) {
1083
- t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
1084
- switch (tbase) {
1085
- case t_base_type::TYPE_VOID:
1086
- throw "compiler error: cannot serialize void field in a struct";
1087
- break;
1088
- case t_base_type::TYPE_STRING:
1089
- out << "readString";
1090
- break;
1091
- case t_base_type::TYPE_BOOL:
1092
- out << "readBool";
1093
- break;
1094
- case t_base_type::TYPE_BYTE:
1095
- out << "readByte";
1096
- break;
1097
- case t_base_type::TYPE_I16:
1098
- out << "readI16";
1099
- break;
1100
- case t_base_type::TYPE_I32:
1101
- out << "readI32";
1102
- break;
1103
- case t_base_type::TYPE_I64:
1104
- out << "readI64";
1105
- break;
1106
- case t_base_type::TYPE_DOUBLE:
1107
- out << "readDouble";
1108
- break;
1109
- default:
1110
- throw "compiler error: no PHP name for base type " + t_base_type::t_base_name(tbase);
1111
- }
1112
- out << " iprot";
1113
- } else if (type->is_enum()) {
1114
- string ename = capitalize(type->get_name());
1115
- out << "(do {i <- readI32 iprot; return (toEnum i :: " << ename << ")})";
1116
- } else {
1117
- printf("DO NOT KNOW HOW TO DESERIALIZE TYPE '%s'\n",
1118
- type->get_name().c_str());
1119
- }
1120
- }
1121
-
1122
-
1123
- /**
1124
- * Generates an unserializer for a struct, calling read()
1125
- */
1126
- void t_hs_generator::generate_deserialize_struct(ofstream &out,
1127
- t_struct* tstruct) {
1128
- string name = capitalize(tstruct->get_name());
1129
- out << "(read_" << name << " iprot)";
1130
-
1131
- }
1132
-
1133
- /**
1134
- * Serialize a container by writing out the header followed by
1135
- * data and then a footer.
1136
- */
1137
- void t_hs_generator::generate_deserialize_container(ofstream &out,
1138
- t_type* ttype) {
1139
- string size = tmp("_size");
1140
- string ktype = tmp("_ktype");
1141
- string vtype = tmp("_vtype");
1142
- string etype = tmp("_etype");
1143
- string con = tmp("_con");
1144
-
1145
- t_field fsize(g_type_i32, size);
1146
- t_field fktype(g_type_byte, ktype);
1147
- t_field fvtype(g_type_byte, vtype);
1148
- t_field fetype(g_type_byte, etype);
1149
-
1150
- // Declare variables, read header
1151
- if (ttype->is_map()) {
1152
- out << "(let {f 0 = return []; f n = do {k <- ";
1153
- generate_deserialize_type(out,((t_map*)ttype)->get_key_type());
1154
- out << "; v <- ";
1155
- generate_deserialize_type(out,((t_map*)ttype)->get_val_type());
1156
- out << ";r <- f (n-1); return $ (k,v):r}} in do {("<<ktype<<","<<vtype<<","<<size<<") <- readMapBegin iprot; l <- f " << size << "; return $ Map.fromList l})";
1157
- } else if (ttype->is_set()) {
1158
- out << "(let {f 0 = return []; f n = do {v <- ";
1159
- generate_deserialize_type(out,((t_map*)ttype)->get_key_type());
1160
- out << ";r <- f (n-1); return $ v:r}} in do {("<<etype<<","<<size<<") <- readSetBegin iprot; l <- f " << size << "; return $ Set.fromList l})";
1161
- } else if (ttype->is_list()) {
1162
- out << "(let {f 0 = return []; f n = do {v <- ";
1163
- generate_deserialize_type(out,((t_map*)ttype)->get_key_type());
1164
- out << ";r <- f (n-1); return $ v:r}} in do {("<<etype<<","<<size<<") <- readListBegin iprot; f " << size << "})";
1165
- }
1166
- }
1167
-
1168
-
1169
- /**
1170
- * Serializes a field of any type.
1171
- *
1172
- * @param tfield The field to serialize
1173
- * @param prefix Name to prepend to field name
1174
- */
1175
- void t_hs_generator::generate_serialize_field(ofstream &out,
1176
- t_field* tfield,
1177
- string name) {
1178
- t_type* type = get_true_type(tfield->get_type());
1179
-
1180
- // Do nothing for void types
1181
- if (type->is_void()) {
1182
- throw "CANNOT GENERATE SERIALIZE CODE FOR void TYPE: " +
1183
- tfield->get_name();
1184
- }
1185
-
1186
- if(name.length() == 0){
1187
- name = decapitalize(tfield->get_name());
1188
- }
1189
-
1190
- if (type->is_struct() || type->is_xception()) {
1191
- generate_serialize_struct(out,
1192
- (t_struct*)type,
1193
- name);
1194
- } else if (type->is_container()) {
1195
- generate_serialize_container(out,
1196
- type,
1197
- name);
1198
- } else if (type->is_base_type() || type->is_enum()) {
1199
- if (type->is_base_type()) {
1200
- t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
1201
- switch (tbase) {
1202
- case t_base_type::TYPE_VOID:
1203
- throw
1204
- "compiler error: cannot serialize void field in a struct: " + name;
1205
- break;
1206
- case t_base_type::TYPE_STRING:
1207
- out << "writeString oprot " << name;
1208
- break;
1209
- case t_base_type::TYPE_BOOL:
1210
- out << "writeBool oprot " << name;
1211
- break;
1212
- case t_base_type::TYPE_BYTE:
1213
- out << "writeByte oprot " << name;
1214
- break;
1215
- case t_base_type::TYPE_I16:
1216
- out << "writeI16 oprot " << name;
1217
- break;
1218
- case t_base_type::TYPE_I32:
1219
- out << "writeI32 oprot " << name;
1220
- break;
1221
- case t_base_type::TYPE_I64:
1222
- out << "writeI64 oprot " << name;
1223
- break;
1224
- case t_base_type::TYPE_DOUBLE:
1225
- out << "writeDouble oprot " << name;
1226
- break;
1227
- default:
1228
- throw "compiler error: no hs name for base type " + t_base_type::t_base_name(tbase);
1229
- }
1230
-
1231
- } else if (type->is_enum()) {
1232
- string ename = capitalize(type->get_name());
1233
- out << "writeI32 oprot (fromEnum "<< name << ")";
1234
- }
1235
-
1236
- } else {
1237
- printf("DO NOT KNOW HOW TO SERIALIZE FIELD '%s' TYPE '%s'\n",
1238
- tfield->get_name().c_str(),
1239
- type->get_name().c_str());
1240
- }
1241
- }
1242
-
1243
- /**
1244
- * Serializes all the members of a struct.
1245
- *
1246
- * @param tstruct The struct to serialize
1247
- * @param prefix String prefix to attach to all fields
1248
- */
1249
- void t_hs_generator::generate_serialize_struct(ofstream &out,
1250
- t_struct* tstruct,
1251
- string prefix) {
1252
- out << "write_" << type_name(tstruct) << " oprot " << prefix;
1253
- }
1254
-
1255
- void t_hs_generator::generate_serialize_container(ofstream &out,
1256
- t_type* ttype,
1257
- string prefix) {
1258
- if (ttype->is_map()) {
1259
- string k = tmp("_kiter");
1260
- string v = tmp("_viter");
1261
- out << "(let {f [] = return (); f (("<<k<<","<<v<<"):t) = do {";
1262
- generate_serialize_map_element(out, (t_map*)ttype, k, v);
1263
- out << ";f t}} in do {writeMapBegin oprot ("<< type_to_enum(((t_map*)ttype)->get_key_type())<<","<< type_to_enum(((t_map*)ttype)->get_val_type())<<",Map.size " << prefix << "); f (Map.toList " << prefix << ");writeMapEnd oprot})";
1264
- } else if (ttype->is_set()) {
1265
- string v = tmp("_viter");
1266
- out << "(let {f [] = return (); f ("<<v<<":t) = do {";
1267
- generate_serialize_set_element(out, (t_set*)ttype, v);
1268
- out << ";f t}} in do {writeSetBegin oprot ("<< type_to_enum(((t_set*)ttype)->get_elem_type())<<",Set.size " << prefix << "); f (Set.toList " << prefix << ");writeSetEnd oprot})";
1269
- } else if (ttype->is_list()) {
1270
- string v = tmp("_viter");
1271
- out << "(let {f [] = return (); f ("<<v<<":t) = do {";
1272
- generate_serialize_list_element(out, (t_list*)ttype, v);
1273
- out << ";f t}} in do {writeListBegin oprot ("<< type_to_enum(((t_list*)ttype)->get_elem_type())<<",length " << prefix << "); f " << prefix << ";writeListEnd oprot})";
1274
- }
1275
-
1276
- }
1277
-
1278
- /**
1279
- * Serializes the members of a map.
1280
- *
1281
- */
1282
- void t_hs_generator::generate_serialize_map_element(ofstream &out,
1283
- t_map* tmap,
1284
- string kiter,
1285
- string viter) {
1286
- t_field kfield(tmap->get_key_type(), kiter);
1287
- out << "do {";
1288
- generate_serialize_field(out, &kfield);
1289
- out << ";";
1290
- t_field vfield(tmap->get_val_type(), viter);
1291
- generate_serialize_field(out, &vfield);
1292
- out << "}";
1293
- }
1294
-
1295
- /**
1296
- * Serializes the members of a set.
1297
- */
1298
- void t_hs_generator::generate_serialize_set_element(ofstream &out,
1299
- t_set* tset,
1300
- string iter) {
1301
- t_field efield(tset->get_elem_type(), iter);
1302
- generate_serialize_field(out, &efield);
1303
- }
1304
-
1305
- /**
1306
- * Serializes the members of a list.
1307
- */
1308
- void t_hs_generator::generate_serialize_list_element(ofstream &out,
1309
- t_list* tlist,
1310
- string iter) {
1311
- t_field efield(tlist->get_elem_type(), iter);
1312
- generate_serialize_field(out, &efield);
1313
- }
1314
-
1315
-
1316
- string t_hs_generator::function_type(t_function* tfunc, bool options, bool io, bool method){
1317
- string result="";
1318
-
1319
- const vector<t_field*>& fields = tfunc->get_arglist()->get_members();
1320
- vector<t_field*>::const_iterator f_iter;
1321
- for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
1322
- if(options) result += "Maybe ";
1323
- result += render_hs_type((*f_iter)->get_type(), options);
1324
- result += " -> ";
1325
- }
1326
- if(fields.empty() && !method){
1327
- result += "() -> ";
1328
- }
1329
- if(io) result += "IO ";
1330
- result += render_hs_type(tfunc->get_returntype(), io);
1331
- return result;
1332
- }
1333
-
1334
-
1335
- string t_hs_generator::type_name(t_type* ttype) {
1336
- string prefix = "";
1337
- t_program* program = ttype->get_program();
1338
- if (program != NULL && program != program_) {
1339
- if (!ttype->is_service()) {
1340
- prefix = capitalize(program->get_name()) + "_Types.";
1341
- }
1342
- }
1343
-
1344
- string name = ttype->get_name();
1345
- if(ttype->is_service()){
1346
- name = capitalize(name);
1347
- } else {
1348
- name = capitalize(name);
1349
- }
1350
- return prefix + name;
1351
- }
1352
-
1353
- /**
1354
- * Converts the parse type to a Protocol.t_type enum
1355
- */
1356
- string t_hs_generator::type_to_enum(t_type* type) {
1357
- type = get_true_type(type);
1358
-
1359
- if (type->is_base_type()) {
1360
- t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
1361
- switch (tbase) {
1362
- case t_base_type::TYPE_VOID:
1363
- return "T_VOID";
1364
- case t_base_type::TYPE_STRING:
1365
- return "T_STRING";
1366
- case t_base_type::TYPE_BOOL:
1367
- return "T_BOOL";
1368
- case t_base_type::TYPE_BYTE:
1369
- return "T_BYTE";
1370
- case t_base_type::TYPE_I16:
1371
- return "T_I16";
1372
- case t_base_type::TYPE_I32:
1373
- return "T_I32";
1374
- case t_base_type::TYPE_I64:
1375
- return "T_I64";
1376
- case t_base_type::TYPE_DOUBLE:
1377
- return "T_DOUBLE";
1378
- }
1379
- } else if (type->is_enum()) {
1380
- return "T_I32";
1381
- } else if (type->is_struct() || type->is_xception()) {
1382
- return "T_STRUCT";
1383
- } else if (type->is_map()) {
1384
- return "T_MAP";
1385
- } else if (type->is_set()) {
1386
- return "T_SET";
1387
- } else if (type->is_list()) {
1388
- return "T_LIST";
1389
- }
1390
-
1391
- throw "INVALID TYPE IN type_to_enum: " + type->get_name();
1392
- }
1393
-
1394
- /**
1395
- * Converts the parse type to an haskell type
1396
- */
1397
- string t_hs_generator::render_hs_type(t_type* type, bool needs_parens) {
1398
- type = get_true_type(type);
1399
- string type_repr;
1400
-
1401
- if (type->is_base_type()) {
1402
- t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
1403
- switch (tbase) {
1404
- case t_base_type::TYPE_VOID:
1405
- return "()";
1406
- case t_base_type::TYPE_STRING:
1407
- return "String";
1408
- case t_base_type::TYPE_BOOL:
1409
- return "Bool";
1410
- case t_base_type::TYPE_BYTE:
1411
- return "Int";
1412
- case t_base_type::TYPE_I16:
1413
- return "Int";
1414
- case t_base_type::TYPE_I32:
1415
- return "Int";
1416
- case t_base_type::TYPE_I64:
1417
- return "Int64";
1418
- case t_base_type::TYPE_DOUBLE:
1419
- return "Double";
1420
- }
1421
- } else if (type->is_enum()) {
1422
- return capitalize(((t_enum*)type)->get_name());
1423
- } else if (type->is_struct() || type->is_xception()) {
1424
- return type_name((t_struct*)type);
1425
- } else if (type->is_map()) {
1426
- t_type* ktype = ((t_map*)type)->get_key_type();
1427
- t_type* vtype = ((t_map*)type)->get_val_type();
1428
-
1429
- type_repr = "Map.Map " + render_hs_type(ktype, true) + " " + render_hs_type(vtype, true);
1430
- } else if (type->is_set()) {
1431
- t_type* etype = ((t_set*)type)->get_elem_type();
1432
-
1433
- type_repr = "Set.Set " + render_hs_type(etype, true) ;
1434
- } else if (type->is_list()) {
1435
- t_type* etype = ((t_list*)type)->get_elem_type();
1436
- return "[" + render_hs_type(etype, false) + "]";
1437
- } else {
1438
- throw "INVALID TYPE IN type_to_enum: " + type->get_name();
1439
- }
1440
-
1441
- return needs_parens ? "(" + type_repr + ")" : type_repr;
1442
- }
1443
-
1444
-
1445
- THRIFT_REGISTER_GENERATOR(hs, "Haskell", "");