thrift-mavericks 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +15 -0
  2. data/CHANGELOG +1 -0
  3. data/README +43 -0
  4. data/benchmark/Benchmark.thrift +24 -0
  5. data/benchmark/benchmark.rb +271 -0
  6. data/benchmark/client.rb +74 -0
  7. data/benchmark/gen-rb/benchmark_constants.rb +11 -0
  8. data/benchmark/gen-rb/benchmark_service.rb +80 -0
  9. data/benchmark/gen-rb/benchmark_types.rb +10 -0
  10. data/benchmark/server.rb +82 -0
  11. data/benchmark/thin_server.rb +44 -0
  12. data/ext/binary_protocol_accelerated.c +441 -0
  13. data/ext/binary_protocol_accelerated.h +20 -0
  14. data/ext/compact_protocol.c +618 -0
  15. data/ext/compact_protocol.h +20 -0
  16. data/ext/constants.h +96 -0
  17. data/ext/extconf.rb +30 -0
  18. data/ext/macros.h +41 -0
  19. data/ext/memory_buffer.c +131 -0
  20. data/ext/memory_buffer.h +20 -0
  21. data/ext/protocol.c +185 -0
  22. data/ext/protocol.h +20 -0
  23. data/ext/strlcpy.c +41 -0
  24. data/ext/strlcpy.h +32 -0
  25. data/ext/struct.c +691 -0
  26. data/ext/struct.h +25 -0
  27. data/ext/thrift_native.c +196 -0
  28. data/lib/thrift.rb +64 -0
  29. data/lib/thrift/client.rb +62 -0
  30. data/lib/thrift/core_ext.rb +23 -0
  31. data/lib/thrift/core_ext/fixnum.rb +29 -0
  32. data/lib/thrift/exceptions.rb +84 -0
  33. data/lib/thrift/processor.rb +57 -0
  34. data/lib/thrift/protocol/base_protocol.rb +290 -0
  35. data/lib/thrift/protocol/binary_protocol.rb +229 -0
  36. data/lib/thrift/protocol/binary_protocol_accelerated.rb +39 -0
  37. data/lib/thrift/protocol/compact_protocol.rb +426 -0
  38. data/lib/thrift/serializer/deserializer.rb +33 -0
  39. data/lib/thrift/serializer/serializer.rb +34 -0
  40. data/lib/thrift/server/base_server.rb +31 -0
  41. data/lib/thrift/server/mongrel_http_server.rb +58 -0
  42. data/lib/thrift/server/nonblocking_server.rb +305 -0
  43. data/lib/thrift/server/simple_server.rb +43 -0
  44. data/lib/thrift/server/thread_pool_server.rb +75 -0
  45. data/lib/thrift/server/threaded_server.rb +47 -0
  46. data/lib/thrift/struct.rb +237 -0
  47. data/lib/thrift/struct_union.rb +192 -0
  48. data/lib/thrift/thrift_native.rb +24 -0
  49. data/lib/thrift/transport/base_server_transport.rb +37 -0
  50. data/lib/thrift/transport/base_transport.rb +107 -0
  51. data/lib/thrift/transport/buffered_transport.rb +108 -0
  52. data/lib/thrift/transport/framed_transport.rb +116 -0
  53. data/lib/thrift/transport/http_client_transport.rb +51 -0
  54. data/lib/thrift/transport/io_stream_transport.rb +39 -0
  55. data/lib/thrift/transport/memory_buffer_transport.rb +125 -0
  56. data/lib/thrift/transport/server_socket.rb +63 -0
  57. data/lib/thrift/transport/socket.rb +137 -0
  58. data/lib/thrift/transport/unix_server_socket.rb +60 -0
  59. data/lib/thrift/transport/unix_socket.rb +40 -0
  60. data/lib/thrift/types.rb +101 -0
  61. data/lib/thrift/union.rb +179 -0
  62. data/spec/ThriftSpec.thrift +132 -0
  63. data/spec/base_protocol_spec.rb +160 -0
  64. data/spec/base_transport_spec.rb +351 -0
  65. data/spec/binary_protocol_accelerated_spec.rb +46 -0
  66. data/spec/binary_protocol_spec.rb +61 -0
  67. data/spec/binary_protocol_spec_shared.rb +375 -0
  68. data/spec/client_spec.rb +100 -0
  69. data/spec/compact_protocol_spec.rb +144 -0
  70. data/spec/exception_spec.rb +142 -0
  71. data/spec/gen-rb/nonblocking_service.rb +272 -0
  72. data/spec/gen-rb/thrift_spec_constants.rb +11 -0
  73. data/spec/gen-rb/thrift_spec_types.rb +346 -0
  74. data/spec/http_client_spec.rb +64 -0
  75. data/spec/mongrel_http_server_spec.rb +117 -0
  76. data/spec/nonblocking_server_spec.rb +265 -0
  77. data/spec/processor_spec.rb +83 -0
  78. data/spec/serializer_spec.rb +69 -0
  79. data/spec/server_socket_spec.rb +80 -0
  80. data/spec/server_spec.rb +159 -0
  81. data/spec/socket_spec.rb +61 -0
  82. data/spec/socket_spec_shared.rb +104 -0
  83. data/spec/spec_helper.rb +58 -0
  84. data/spec/struct_spec.rb +295 -0
  85. data/spec/types_spec.rb +116 -0
  86. data/spec/union_spec.rb +193 -0
  87. data/spec/unix_socket_spec.rb +108 -0
  88. data/test/debug_proto/gen-rb/debug_proto_test_constants.rb +274 -0
  89. data/test/debug_proto/gen-rb/debug_proto_test_types.rb +761 -0
  90. data/test/debug_proto/gen-rb/empty_service.rb +24 -0
  91. data/test/debug_proto/gen-rb/inherited.rb +79 -0
  92. data/test/debug_proto/gen-rb/reverse_order_service.rb +82 -0
  93. data/test/debug_proto/gen-rb/service_for_exception_with_a_map.rb +81 -0
  94. data/test/debug_proto/gen-rb/srv.rb +330 -0
  95. metadata +281 -0
@@ -0,0 +1,761 @@
1
+ #
2
+ # Autogenerated by Thrift Compiler (0.9.0)
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'thrift'
8
+
9
+ module SomeEnum
10
+ ONE = 1
11
+ TWO = 2
12
+ VALUE_MAP = {1 => "ONE", 2 => "TWO"}
13
+ VALID_VALUES = Set.new([ONE, TWO]).freeze
14
+ end
15
+
16
+ class Doubles
17
+ include ::Thrift::Struct, ::Thrift::Struct_Union
18
+ NAN = 1
19
+ INF = 2
20
+ NEGINF = 3
21
+ REPEATING = 4
22
+ BIG = 5
23
+ SMALL = 6
24
+ ZERO = 7
25
+ NEGZERO = 8
26
+
27
+ FIELDS = {
28
+ NAN => {:type => ::Thrift::Types::DOUBLE, :name => 'nan'},
29
+ INF => {:type => ::Thrift::Types::DOUBLE, :name => 'inf'},
30
+ NEGINF => {:type => ::Thrift::Types::DOUBLE, :name => 'neginf'},
31
+ REPEATING => {:type => ::Thrift::Types::DOUBLE, :name => 'repeating'},
32
+ BIG => {:type => ::Thrift::Types::DOUBLE, :name => 'big'},
33
+ SMALL => {:type => ::Thrift::Types::DOUBLE, :name => 'small'},
34
+ ZERO => {:type => ::Thrift::Types::DOUBLE, :name => 'zero'},
35
+ NEGZERO => {:type => ::Thrift::Types::DOUBLE, :name => 'negzero'}
36
+ }
37
+
38
+ def struct_fields; FIELDS; end
39
+
40
+ def validate
41
+ end
42
+
43
+ ::Thrift::Struct.generate_accessors self
44
+ end
45
+
46
+ class OneOfEach
47
+ include ::Thrift::Struct, ::Thrift::Struct_Union
48
+ IM_TRUE = 1
49
+ IM_FALSE = 2
50
+ A_BITE = 3
51
+ INTEGER16 = 4
52
+ INTEGER32 = 5
53
+ INTEGER64 = 6
54
+ DOUBLE_PRECISION = 7
55
+ SOME_CHARACTERS = 8
56
+ ZOMG_UNICODE = 9
57
+ WHAT_WHO = 10
58
+ BASE64 = 11
59
+ BYTE_LIST = 12
60
+ I16_LIST = 13
61
+ I64_LIST = 14
62
+
63
+ FIELDS = {
64
+ IM_TRUE => {:type => ::Thrift::Types::BOOL, :name => 'im_true'},
65
+ IM_FALSE => {:type => ::Thrift::Types::BOOL, :name => 'im_false'},
66
+ A_BITE => {:type => ::Thrift::Types::BYTE, :name => 'a_bite', :default => 127},
67
+ INTEGER16 => {:type => ::Thrift::Types::I16, :name => 'integer16', :default => 32767},
68
+ INTEGER32 => {:type => ::Thrift::Types::I32, :name => 'integer32'},
69
+ INTEGER64 => {:type => ::Thrift::Types::I64, :name => 'integer64', :default => 10000000000},
70
+ DOUBLE_PRECISION => {:type => ::Thrift::Types::DOUBLE, :name => 'double_precision'},
71
+ SOME_CHARACTERS => {:type => ::Thrift::Types::STRING, :name => 'some_characters'},
72
+ ZOMG_UNICODE => {:type => ::Thrift::Types::STRING, :name => 'zomg_unicode'},
73
+ WHAT_WHO => {:type => ::Thrift::Types::BOOL, :name => 'what_who'},
74
+ BASE64 => {:type => ::Thrift::Types::STRING, :name => 'base64', :binary => true},
75
+ BYTE_LIST => {:type => ::Thrift::Types::LIST, :name => 'byte_list', :default => [
76
+ 1,
77
+ 2,
78
+ 3,
79
+ ], :element => {:type => ::Thrift::Types::BYTE}},
80
+ I16_LIST => {:type => ::Thrift::Types::LIST, :name => 'i16_list', :default => [
81
+ 1,
82
+ 2,
83
+ 3,
84
+ ], :element => {:type => ::Thrift::Types::I16}},
85
+ I64_LIST => {:type => ::Thrift::Types::LIST, :name => 'i64_list', :default => [
86
+ 1,
87
+ 2,
88
+ 3,
89
+ ], :element => {:type => ::Thrift::Types::I64}}
90
+ }
91
+
92
+ def struct_fields; FIELDS; end
93
+
94
+ def validate
95
+ end
96
+
97
+ ::Thrift::Struct.generate_accessors self
98
+ end
99
+
100
+ class Bonk
101
+ include ::Thrift::Struct, ::Thrift::Struct_Union
102
+ TYPE = 1
103
+ MESSAGE = 2
104
+
105
+ FIELDS = {
106
+ TYPE => {:type => ::Thrift::Types::I32, :name => 'type'},
107
+ MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'}
108
+ }
109
+
110
+ def struct_fields; FIELDS; end
111
+
112
+ def validate
113
+ end
114
+
115
+ ::Thrift::Struct.generate_accessors self
116
+ end
117
+
118
+ class Nesting
119
+ include ::Thrift::Struct, ::Thrift::Struct_Union
120
+ MY_BONK = 1
121
+ MY_OOE = 2
122
+
123
+ FIELDS = {
124
+ MY_BONK => {:type => ::Thrift::Types::STRUCT, :name => 'my_bonk', :class => ::Bonk},
125
+ MY_OOE => {:type => ::Thrift::Types::STRUCT, :name => 'my_ooe', :class => ::OneOfEach}
126
+ }
127
+
128
+ def struct_fields; FIELDS; end
129
+
130
+ def validate
131
+ end
132
+
133
+ ::Thrift::Struct.generate_accessors self
134
+ end
135
+
136
+ class HolyMoley
137
+ include ::Thrift::Struct, ::Thrift::Struct_Union
138
+ BIG = 1
139
+ CONTAIN = 2
140
+ BONKS = 3
141
+
142
+ FIELDS = {
143
+ BIG => {:type => ::Thrift::Types::LIST, :name => 'big', :element => {:type => ::Thrift::Types::STRUCT, :class => ::OneOfEach}},
144
+ CONTAIN => {:type => ::Thrift::Types::SET, :name => 'contain', :element => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::STRING}}},
145
+ BONKS => {:type => ::Thrift::Types::MAP, :name => 'bonks', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::STRUCT, :class => ::Bonk}}}
146
+ }
147
+
148
+ def struct_fields; FIELDS; end
149
+
150
+ def validate
151
+ end
152
+
153
+ ::Thrift::Struct.generate_accessors self
154
+ end
155
+
156
+ class Backwards
157
+ include ::Thrift::Struct, ::Thrift::Struct_Union
158
+ FIRST_TAG2 = 2
159
+ SECOND_TAG1 = 1
160
+
161
+ FIELDS = {
162
+ FIRST_TAG2 => {:type => ::Thrift::Types::I32, :name => 'first_tag2'},
163
+ SECOND_TAG1 => {:type => ::Thrift::Types::I32, :name => 'second_tag1'}
164
+ }
165
+
166
+ def struct_fields; FIELDS; end
167
+
168
+ def validate
169
+ end
170
+
171
+ ::Thrift::Struct.generate_accessors self
172
+ end
173
+
174
+ class Empty
175
+ include ::Thrift::Struct, ::Thrift::Struct_Union
176
+
177
+ FIELDS = {
178
+
179
+ }
180
+
181
+ def struct_fields; FIELDS; end
182
+
183
+ def validate
184
+ end
185
+
186
+ ::Thrift::Struct.generate_accessors self
187
+ end
188
+
189
+ class Wrapper
190
+ include ::Thrift::Struct, ::Thrift::Struct_Union
191
+ FOO = 1
192
+
193
+ FIELDS = {
194
+ FOO => {:type => ::Thrift::Types::STRUCT, :name => 'foo', :class => ::Empty}
195
+ }
196
+
197
+ def struct_fields; FIELDS; end
198
+
199
+ def validate
200
+ end
201
+
202
+ ::Thrift::Struct.generate_accessors self
203
+ end
204
+
205
+ class RandomStuff
206
+ include ::Thrift::Struct, ::Thrift::Struct_Union
207
+ A = 1
208
+ B = 2
209
+ C = 3
210
+ D = 4
211
+ MYINTLIST = 5
212
+ MAPS = 6
213
+ BIGINT = 7
214
+ TRIPLE = 8
215
+
216
+ FIELDS = {
217
+ A => {:type => ::Thrift::Types::I32, :name => 'a'},
218
+ B => {:type => ::Thrift::Types::I32, :name => 'b'},
219
+ C => {:type => ::Thrift::Types::I32, :name => 'c'},
220
+ D => {:type => ::Thrift::Types::I32, :name => 'd'},
221
+ MYINTLIST => {:type => ::Thrift::Types::LIST, :name => 'myintlist', :element => {:type => ::Thrift::Types::I32}},
222
+ MAPS => {:type => ::Thrift::Types::MAP, :name => 'maps', :key => {:type => ::Thrift::Types::I32}, :value => {:type => ::Thrift::Types::STRUCT, :class => ::Wrapper}},
223
+ BIGINT => {:type => ::Thrift::Types::I64, :name => 'bigint'},
224
+ TRIPLE => {:type => ::Thrift::Types::DOUBLE, :name => 'triple'}
225
+ }
226
+
227
+ def struct_fields; FIELDS; end
228
+
229
+ def validate
230
+ end
231
+
232
+ ::Thrift::Struct.generate_accessors self
233
+ end
234
+
235
+ class Base64
236
+ include ::Thrift::Struct, ::Thrift::Struct_Union
237
+ A = 1
238
+ B1 = 2
239
+ B2 = 3
240
+ B3 = 4
241
+ B4 = 5
242
+ B5 = 6
243
+ B6 = 7
244
+
245
+ FIELDS = {
246
+ A => {:type => ::Thrift::Types::I32, :name => 'a'},
247
+ B1 => {:type => ::Thrift::Types::STRING, :name => 'b1', :binary => true},
248
+ B2 => {:type => ::Thrift::Types::STRING, :name => 'b2', :binary => true},
249
+ B3 => {:type => ::Thrift::Types::STRING, :name => 'b3', :binary => true},
250
+ B4 => {:type => ::Thrift::Types::STRING, :name => 'b4', :binary => true},
251
+ B5 => {:type => ::Thrift::Types::STRING, :name => 'b5', :binary => true},
252
+ B6 => {:type => ::Thrift::Types::STRING, :name => 'b6', :binary => true}
253
+ }
254
+
255
+ def struct_fields; FIELDS; end
256
+
257
+ def validate
258
+ end
259
+
260
+ ::Thrift::Struct.generate_accessors self
261
+ end
262
+
263
+ class CompactProtoTestStruct
264
+ include ::Thrift::Struct, ::Thrift::Struct_Union
265
+ A_BYTE = 1
266
+ A_I16 = 2
267
+ A_I32 = 3
268
+ A_I64 = 4
269
+ A_DOUBLE = 5
270
+ A_STRING = 6
271
+ A_BINARY = 7
272
+ TRUE_FIELD = 8
273
+ FALSE_FIELD = 9
274
+ EMPTY_STRUCT_FIELD = 10
275
+ BYTE_LIST = 11
276
+ I16_LIST = 12
277
+ I32_LIST = 13
278
+ I64_LIST = 14
279
+ DOUBLE_LIST = 15
280
+ STRING_LIST = 16
281
+ BINARY_LIST = 17
282
+ BOOLEAN_LIST = 18
283
+ STRUCT_LIST = 19
284
+ BYTE_SET = 20
285
+ I16_SET = 21
286
+ I32_SET = 22
287
+ I64_SET = 23
288
+ DOUBLE_SET = 24
289
+ STRING_SET = 25
290
+ BINARY_SET = 26
291
+ BOOLEAN_SET = 27
292
+ STRUCT_SET = 28
293
+ BYTE_BYTE_MAP = 29
294
+ I16_BYTE_MAP = 30
295
+ I32_BYTE_MAP = 31
296
+ I64_BYTE_MAP = 32
297
+ DOUBLE_BYTE_MAP = 33
298
+ STRING_BYTE_MAP = 34
299
+ BINARY_BYTE_MAP = 35
300
+ BOOLEAN_BYTE_MAP = 36
301
+ BYTE_I16_MAP = 37
302
+ BYTE_I32_MAP = 38
303
+ BYTE_I64_MAP = 39
304
+ BYTE_DOUBLE_MAP = 40
305
+ BYTE_STRING_MAP = 41
306
+ BYTE_BINARY_MAP = 42
307
+ BYTE_BOOLEAN_MAP = 43
308
+ LIST_BYTE_MAP = 44
309
+ SET_BYTE_MAP = 45
310
+ MAP_BYTE_MAP = 46
311
+ BYTE_MAP_MAP = 47
312
+ BYTE_SET_MAP = 48
313
+ BYTE_LIST_MAP = 49
314
+
315
+ FIELDS = {
316
+ A_BYTE => {:type => ::Thrift::Types::BYTE, :name => 'a_byte'},
317
+ A_I16 => {:type => ::Thrift::Types::I16, :name => 'a_i16'},
318
+ A_I32 => {:type => ::Thrift::Types::I32, :name => 'a_i32'},
319
+ A_I64 => {:type => ::Thrift::Types::I64, :name => 'a_i64'},
320
+ A_DOUBLE => {:type => ::Thrift::Types::DOUBLE, :name => 'a_double'},
321
+ A_STRING => {:type => ::Thrift::Types::STRING, :name => 'a_string'},
322
+ A_BINARY => {:type => ::Thrift::Types::STRING, :name => 'a_binary', :binary => true},
323
+ TRUE_FIELD => {:type => ::Thrift::Types::BOOL, :name => 'true_field'},
324
+ FALSE_FIELD => {:type => ::Thrift::Types::BOOL, :name => 'false_field'},
325
+ EMPTY_STRUCT_FIELD => {:type => ::Thrift::Types::STRUCT, :name => 'empty_struct_field', :class => ::Empty},
326
+ BYTE_LIST => {:type => ::Thrift::Types::LIST, :name => 'byte_list', :element => {:type => ::Thrift::Types::BYTE}},
327
+ I16_LIST => {:type => ::Thrift::Types::LIST, :name => 'i16_list', :element => {:type => ::Thrift::Types::I16}},
328
+ I32_LIST => {:type => ::Thrift::Types::LIST, :name => 'i32_list', :element => {:type => ::Thrift::Types::I32}},
329
+ I64_LIST => {:type => ::Thrift::Types::LIST, :name => 'i64_list', :element => {:type => ::Thrift::Types::I64}},
330
+ DOUBLE_LIST => {:type => ::Thrift::Types::LIST, :name => 'double_list', :element => {:type => ::Thrift::Types::DOUBLE}},
331
+ STRING_LIST => {:type => ::Thrift::Types::LIST, :name => 'string_list', :element => {:type => ::Thrift::Types::STRING}},
332
+ BINARY_LIST => {:type => ::Thrift::Types::LIST, :name => 'binary_list', :element => {:type => ::Thrift::Types::STRING, :binary => true}},
333
+ BOOLEAN_LIST => {:type => ::Thrift::Types::LIST, :name => 'boolean_list', :element => {:type => ::Thrift::Types::BOOL}},
334
+ STRUCT_LIST => {:type => ::Thrift::Types::LIST, :name => 'struct_list', :element => {:type => ::Thrift::Types::STRUCT, :class => ::Empty}},
335
+ BYTE_SET => {:type => ::Thrift::Types::SET, :name => 'byte_set', :element => {:type => ::Thrift::Types::BYTE}},
336
+ I16_SET => {:type => ::Thrift::Types::SET, :name => 'i16_set', :element => {:type => ::Thrift::Types::I16}},
337
+ I32_SET => {:type => ::Thrift::Types::SET, :name => 'i32_set', :element => {:type => ::Thrift::Types::I32}},
338
+ I64_SET => {:type => ::Thrift::Types::SET, :name => 'i64_set', :element => {:type => ::Thrift::Types::I64}},
339
+ DOUBLE_SET => {:type => ::Thrift::Types::SET, :name => 'double_set', :element => {:type => ::Thrift::Types::DOUBLE}},
340
+ STRING_SET => {:type => ::Thrift::Types::SET, :name => 'string_set', :element => {:type => ::Thrift::Types::STRING}},
341
+ BINARY_SET => {:type => ::Thrift::Types::SET, :name => 'binary_set', :element => {:type => ::Thrift::Types::STRING, :binary => true}},
342
+ BOOLEAN_SET => {:type => ::Thrift::Types::SET, :name => 'boolean_set', :element => {:type => ::Thrift::Types::BOOL}},
343
+ STRUCT_SET => {:type => ::Thrift::Types::SET, :name => 'struct_set', :element => {:type => ::Thrift::Types::STRUCT, :class => ::Empty}},
344
+ BYTE_BYTE_MAP => {:type => ::Thrift::Types::MAP, :name => 'byte_byte_map', :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::BYTE}},
345
+ I16_BYTE_MAP => {:type => ::Thrift::Types::MAP, :name => 'i16_byte_map', :key => {:type => ::Thrift::Types::I16}, :value => {:type => ::Thrift::Types::BYTE}},
346
+ I32_BYTE_MAP => {:type => ::Thrift::Types::MAP, :name => 'i32_byte_map', :key => {:type => ::Thrift::Types::I32}, :value => {:type => ::Thrift::Types::BYTE}},
347
+ I64_BYTE_MAP => {:type => ::Thrift::Types::MAP, :name => 'i64_byte_map', :key => {:type => ::Thrift::Types::I64}, :value => {:type => ::Thrift::Types::BYTE}},
348
+ DOUBLE_BYTE_MAP => {:type => ::Thrift::Types::MAP, :name => 'double_byte_map', :key => {:type => ::Thrift::Types::DOUBLE}, :value => {:type => ::Thrift::Types::BYTE}},
349
+ STRING_BYTE_MAP => {:type => ::Thrift::Types::MAP, :name => 'string_byte_map', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::BYTE}},
350
+ BINARY_BYTE_MAP => {:type => ::Thrift::Types::MAP, :name => 'binary_byte_map', :key => {:type => ::Thrift::Types::STRING, :binary => true}, :value => {:type => ::Thrift::Types::BYTE}},
351
+ BOOLEAN_BYTE_MAP => {:type => ::Thrift::Types::MAP, :name => 'boolean_byte_map', :key => {:type => ::Thrift::Types::BOOL}, :value => {:type => ::Thrift::Types::BYTE}},
352
+ BYTE_I16_MAP => {:type => ::Thrift::Types::MAP, :name => 'byte_i16_map', :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::I16}},
353
+ BYTE_I32_MAP => {:type => ::Thrift::Types::MAP, :name => 'byte_i32_map', :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::I32}},
354
+ BYTE_I64_MAP => {:type => ::Thrift::Types::MAP, :name => 'byte_i64_map', :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::I64}},
355
+ BYTE_DOUBLE_MAP => {:type => ::Thrift::Types::MAP, :name => 'byte_double_map', :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::DOUBLE}},
356
+ BYTE_STRING_MAP => {:type => ::Thrift::Types::MAP, :name => 'byte_string_map', :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::STRING}},
357
+ BYTE_BINARY_MAP => {:type => ::Thrift::Types::MAP, :name => 'byte_binary_map', :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::STRING, :binary => true}},
358
+ BYTE_BOOLEAN_MAP => {:type => ::Thrift::Types::MAP, :name => 'byte_boolean_map', :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::BOOL}},
359
+ LIST_BYTE_MAP => {:type => ::Thrift::Types::MAP, :name => 'list_byte_map', :key => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::BYTE}}, :value => {:type => ::Thrift::Types::BYTE}},
360
+ SET_BYTE_MAP => {:type => ::Thrift::Types::MAP, :name => 'set_byte_map', :key => {:type => ::Thrift::Types::SET, :element => {:type => ::Thrift::Types::BYTE}}, :value => {:type => ::Thrift::Types::BYTE}},
361
+ MAP_BYTE_MAP => {:type => ::Thrift::Types::MAP, :name => 'map_byte_map', :key => {:type => ::Thrift::Types::MAP, :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::BYTE}}, :value => {:type => ::Thrift::Types::BYTE}},
362
+ BYTE_MAP_MAP => {:type => ::Thrift::Types::MAP, :name => 'byte_map_map', :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::MAP, :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::BYTE}}},
363
+ BYTE_SET_MAP => {:type => ::Thrift::Types::MAP, :name => 'byte_set_map', :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::SET, :element => {:type => ::Thrift::Types::BYTE}}},
364
+ BYTE_LIST_MAP => {:type => ::Thrift::Types::MAP, :name => 'byte_list_map', :key => {:type => ::Thrift::Types::BYTE}, :value => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::BYTE}}}
365
+ }
366
+
367
+ def struct_fields; FIELDS; end
368
+
369
+ def validate
370
+ end
371
+
372
+ ::Thrift::Struct.generate_accessors self
373
+ end
374
+
375
+ class SingleMapTestStruct
376
+ include ::Thrift::Struct, ::Thrift::Struct_Union
377
+ I32_MAP = 1
378
+
379
+ FIELDS = {
380
+ I32_MAP => {:type => ::Thrift::Types::MAP, :name => 'i32_map', :key => {:type => ::Thrift::Types::I32}, :value => {:type => ::Thrift::Types::I32}}
381
+ }
382
+
383
+ def struct_fields; FIELDS; end
384
+
385
+ def validate
386
+ raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field i32_map is unset!') unless @i32_map
387
+ end
388
+
389
+ ::Thrift::Struct.generate_accessors self
390
+ end
391
+
392
+ class ExceptionWithAMap < ::Thrift::Exception
393
+ include ::Thrift::Struct, ::Thrift::Struct_Union
394
+ BLAH = 1
395
+ MAP_FIELD = 2
396
+
397
+ FIELDS = {
398
+ BLAH => {:type => ::Thrift::Types::STRING, :name => 'blah'},
399
+ MAP_FIELD => {:type => ::Thrift::Types::MAP, :name => 'map_field', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}}
400
+ }
401
+
402
+ def struct_fields; FIELDS; end
403
+
404
+ def validate
405
+ end
406
+
407
+ ::Thrift::Struct.generate_accessors self
408
+ end
409
+
410
+ class BlowUp
411
+ include ::Thrift::Struct, ::Thrift::Struct_Union
412
+ B1 = 1
413
+ B2 = 2
414
+ B3 = 3
415
+ B4 = 4
416
+
417
+ FIELDS = {
418
+ B1 => {:type => ::Thrift::Types::MAP, :name => 'b1', :key => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::I32}}, :value => {:type => ::Thrift::Types::SET, :element => {:type => ::Thrift::Types::MAP, :key => {:type => ::Thrift::Types::I32}, :value => {:type => ::Thrift::Types::STRING}}}},
419
+ B2 => {:type => ::Thrift::Types::MAP, :name => 'b2', :key => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::I32}}, :value => {:type => ::Thrift::Types::SET, :element => {:type => ::Thrift::Types::MAP, :key => {:type => ::Thrift::Types::I32}, :value => {:type => ::Thrift::Types::STRING}}}},
420
+ B3 => {:type => ::Thrift::Types::MAP, :name => 'b3', :key => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::I32}}, :value => {:type => ::Thrift::Types::SET, :element => {:type => ::Thrift::Types::MAP, :key => {:type => ::Thrift::Types::I32}, :value => {:type => ::Thrift::Types::STRING}}}},
421
+ B4 => {:type => ::Thrift::Types::MAP, :name => 'b4', :key => {:type => ::Thrift::Types::LIST, :element => {:type => ::Thrift::Types::I32}}, :value => {:type => ::Thrift::Types::SET, :element => {:type => ::Thrift::Types::MAP, :key => {:type => ::Thrift::Types::I32}, :value => {:type => ::Thrift::Types::STRING}}}}
422
+ }
423
+
424
+ def struct_fields; FIELDS; end
425
+
426
+ def validate
427
+ end
428
+
429
+ ::Thrift::Struct.generate_accessors self
430
+ end
431
+
432
+ class ReverseOrderStruct
433
+ include ::Thrift::Struct, ::Thrift::Struct_Union
434
+ FIRST = 4
435
+ SECOND = 3
436
+ THIRD = 2
437
+ FOURTH = 1
438
+
439
+ FIELDS = {
440
+ FIRST => {:type => ::Thrift::Types::STRING, :name => 'first'},
441
+ SECOND => {:type => ::Thrift::Types::I16, :name => 'second'},
442
+ THIRD => {:type => ::Thrift::Types::I32, :name => 'third'},
443
+ FOURTH => {:type => ::Thrift::Types::I64, :name => 'fourth'}
444
+ }
445
+
446
+ def struct_fields; FIELDS; end
447
+
448
+ def validate
449
+ end
450
+
451
+ ::Thrift::Struct.generate_accessors self
452
+ end
453
+
454
+ class StructWithSomeEnum
455
+ include ::Thrift::Struct, ::Thrift::Struct_Union
456
+ BLAH = 1
457
+
458
+ FIELDS = {
459
+ BLAH => {:type => ::Thrift::Types::I32, :name => 'blah', :enum_class => ::SomeEnum}
460
+ }
461
+
462
+ def struct_fields; FIELDS; end
463
+
464
+ def validate
465
+ unless @blah.nil? || ::SomeEnum::VALID_VALUES.include?(@blah)
466
+ raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field blah!')
467
+ end
468
+ end
469
+
470
+ ::Thrift::Struct.generate_accessors self
471
+ end
472
+
473
+ class TestUnion < ::Thrift::Union
474
+ include ::Thrift::Struct_Union
475
+ class << self
476
+ def string_field(val)
477
+ TestUnion.new(:string_field, val)
478
+ end
479
+
480
+ def i32_field(val)
481
+ TestUnion.new(:i32_field, val)
482
+ end
483
+
484
+ def struct_field(val)
485
+ TestUnion.new(:struct_field, val)
486
+ end
487
+
488
+ def struct_list(val)
489
+ TestUnion.new(:struct_list, val)
490
+ end
491
+
492
+ def other_i32_field(val)
493
+ TestUnion.new(:other_i32_field, val)
494
+ end
495
+
496
+ def enum_field(val)
497
+ TestUnion.new(:enum_field, val)
498
+ end
499
+
500
+ def i32_set(val)
501
+ TestUnion.new(:i32_set, val)
502
+ end
503
+
504
+ def i32_map(val)
505
+ TestUnion.new(:i32_map, val)
506
+ end
507
+ end
508
+
509
+ STRING_FIELD = 1
510
+ I32_FIELD = 2
511
+ STRUCT_FIELD = 3
512
+ STRUCT_LIST = 4
513
+ OTHER_I32_FIELD = 5
514
+ ENUM_FIELD = 6
515
+ I32_SET = 7
516
+ I32_MAP = 8
517
+
518
+ FIELDS = {
519
+ # A doc string
520
+ STRING_FIELD => {:type => ::Thrift::Types::STRING, :name => 'string_field'},
521
+ I32_FIELD => {:type => ::Thrift::Types::I32, :name => 'i32_field'},
522
+ STRUCT_FIELD => {:type => ::Thrift::Types::STRUCT, :name => 'struct_field', :class => ::OneOfEach},
523
+ STRUCT_LIST => {:type => ::Thrift::Types::LIST, :name => 'struct_list', :element => {:type => ::Thrift::Types::STRUCT, :class => ::RandomStuff}},
524
+ OTHER_I32_FIELD => {:type => ::Thrift::Types::I32, :name => 'other_i32_field'},
525
+ ENUM_FIELD => {:type => ::Thrift::Types::I32, :name => 'enum_field', :enum_class => ::SomeEnum},
526
+ I32_SET => {:type => ::Thrift::Types::SET, :name => 'i32_set', :element => {:type => ::Thrift::Types::I32}},
527
+ I32_MAP => {:type => ::Thrift::Types::MAP, :name => 'i32_map', :key => {:type => ::Thrift::Types::I32}, :value => {:type => ::Thrift::Types::I32}}
528
+ }
529
+
530
+ def struct_fields; FIELDS; end
531
+
532
+ def validate
533
+ raise(StandardError, 'Union fields are not set.') if get_set_field.nil? || get_value.nil?
534
+ if get_set_field == :enum_field
535
+ raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field enum_field!') unless ::SomeEnum::VALID_VALUES.include?(get_value)
536
+ end
537
+ end
538
+
539
+ ::Thrift::Union.generate_accessors self
540
+ end
541
+
542
+ class TestUnionMinusStringField < ::Thrift::Union
543
+ include ::Thrift::Struct_Union
544
+ class << self
545
+ def i32_field(val)
546
+ TestUnionMinusStringField.new(:i32_field, val)
547
+ end
548
+
549
+ def struct_field(val)
550
+ TestUnionMinusStringField.new(:struct_field, val)
551
+ end
552
+
553
+ def struct_list(val)
554
+ TestUnionMinusStringField.new(:struct_list, val)
555
+ end
556
+
557
+ def other_i32_field(val)
558
+ TestUnionMinusStringField.new(:other_i32_field, val)
559
+ end
560
+
561
+ def enum_field(val)
562
+ TestUnionMinusStringField.new(:enum_field, val)
563
+ end
564
+
565
+ def i32_set(val)
566
+ TestUnionMinusStringField.new(:i32_set, val)
567
+ end
568
+
569
+ def i32_map(val)
570
+ TestUnionMinusStringField.new(:i32_map, val)
571
+ end
572
+ end
573
+
574
+ I32_FIELD = 2
575
+ STRUCT_FIELD = 3
576
+ STRUCT_LIST = 4
577
+ OTHER_I32_FIELD = 5
578
+ ENUM_FIELD = 6
579
+ I32_SET = 7
580
+ I32_MAP = 8
581
+
582
+ FIELDS = {
583
+ I32_FIELD => {:type => ::Thrift::Types::I32, :name => 'i32_field'},
584
+ STRUCT_FIELD => {:type => ::Thrift::Types::STRUCT, :name => 'struct_field', :class => ::OneOfEach},
585
+ STRUCT_LIST => {:type => ::Thrift::Types::LIST, :name => 'struct_list', :element => {:type => ::Thrift::Types::STRUCT, :class => ::RandomStuff}},
586
+ OTHER_I32_FIELD => {:type => ::Thrift::Types::I32, :name => 'other_i32_field'},
587
+ ENUM_FIELD => {:type => ::Thrift::Types::I32, :name => 'enum_field', :enum_class => ::SomeEnum},
588
+ I32_SET => {:type => ::Thrift::Types::SET, :name => 'i32_set', :element => {:type => ::Thrift::Types::I32}},
589
+ I32_MAP => {:type => ::Thrift::Types::MAP, :name => 'i32_map', :key => {:type => ::Thrift::Types::I32}, :value => {:type => ::Thrift::Types::I32}}
590
+ }
591
+
592
+ def struct_fields; FIELDS; end
593
+
594
+ def validate
595
+ raise(StandardError, 'Union fields are not set.') if get_set_field.nil? || get_value.nil?
596
+ if get_set_field == :enum_field
597
+ raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field enum_field!') unless ::SomeEnum::VALID_VALUES.include?(get_value)
598
+ end
599
+ end
600
+
601
+ ::Thrift::Union.generate_accessors self
602
+ end
603
+
604
+ class ComparableUnion < ::Thrift::Union
605
+ include ::Thrift::Struct_Union
606
+ class << self
607
+ def string_field(val)
608
+ ComparableUnion.new(:string_field, val)
609
+ end
610
+
611
+ def binary_field(val)
612
+ ComparableUnion.new(:binary_field, val)
613
+ end
614
+ end
615
+
616
+ STRING_FIELD = 1
617
+ BINARY_FIELD = 2
618
+
619
+ FIELDS = {
620
+ STRING_FIELD => {:type => ::Thrift::Types::STRING, :name => 'string_field'},
621
+ BINARY_FIELD => {:type => ::Thrift::Types::STRING, :name => 'binary_field', :binary => true}
622
+ }
623
+
624
+ def struct_fields; FIELDS; end
625
+
626
+ def validate
627
+ raise(StandardError, 'Union fields are not set.') if get_set_field.nil? || get_value.nil?
628
+ end
629
+
630
+ ::Thrift::Union.generate_accessors self
631
+ end
632
+
633
+ class StructWithAUnion
634
+ include ::Thrift::Struct, ::Thrift::Struct_Union
635
+ TEST_UNION = 1
636
+
637
+ FIELDS = {
638
+ TEST_UNION => {:type => ::Thrift::Types::STRUCT, :name => 'test_union', :class => ::TestUnion}
639
+ }
640
+
641
+ def struct_fields; FIELDS; end
642
+
643
+ def validate
644
+ end
645
+
646
+ ::Thrift::Struct.generate_accessors self
647
+ end
648
+
649
+ class PrimitiveThenStruct
650
+ include ::Thrift::Struct, ::Thrift::Struct_Union
651
+ BLAH = 1
652
+ BLAH2 = 2
653
+ BW = 3
654
+
655
+ FIELDS = {
656
+ BLAH => {:type => ::Thrift::Types::I32, :name => 'blah'},
657
+ BLAH2 => {:type => ::Thrift::Types::I32, :name => 'blah2'},
658
+ BW => {:type => ::Thrift::Types::STRUCT, :name => 'bw', :class => ::Backwards}
659
+ }
660
+
661
+ def struct_fields; FIELDS; end
662
+
663
+ def validate
664
+ end
665
+
666
+ ::Thrift::Struct.generate_accessors self
667
+ end
668
+
669
+ class StructWithASomemap
670
+ include ::Thrift::Struct, ::Thrift::Struct_Union
671
+ SOMEMAP_FIELD = 1
672
+
673
+ FIELDS = {
674
+ SOMEMAP_FIELD => {:type => ::Thrift::Types::MAP, :name => 'somemap_field', :key => {:type => ::Thrift::Types::I32}, :value => {:type => ::Thrift::Types::I32}}
675
+ }
676
+
677
+ def struct_fields; FIELDS; end
678
+
679
+ def validate
680
+ raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field somemap_field is unset!') unless @somemap_field
681
+ end
682
+
683
+ ::Thrift::Struct.generate_accessors self
684
+ end
685
+
686
+ class BigFieldIdStruct
687
+ include ::Thrift::Struct, ::Thrift::Struct_Union
688
+ FIELD1 = 1
689
+ FIELD2 = 45
690
+
691
+ FIELDS = {
692
+ FIELD1 => {:type => ::Thrift::Types::STRING, :name => 'field1'},
693
+ FIELD2 => {:type => ::Thrift::Types::STRING, :name => 'field2'}
694
+ }
695
+
696
+ def struct_fields; FIELDS; end
697
+
698
+ def validate
699
+ end
700
+
701
+ ::Thrift::Struct.generate_accessors self
702
+ end
703
+
704
+ class BreaksRubyCompactProtocol
705
+ include ::Thrift::Struct, ::Thrift::Struct_Union
706
+ FIELD1 = 1
707
+ FIELD2 = 2
708
+ FIELD3 = 3
709
+
710
+ FIELDS = {
711
+ FIELD1 => {:type => ::Thrift::Types::STRING, :name => 'field1'},
712
+ FIELD2 => {:type => ::Thrift::Types::STRUCT, :name => 'field2', :class => ::BigFieldIdStruct},
713
+ FIELD3 => {:type => ::Thrift::Types::I32, :name => 'field3'}
714
+ }
715
+
716
+ def struct_fields; FIELDS; end
717
+
718
+ def validate
719
+ end
720
+
721
+ ::Thrift::Struct.generate_accessors self
722
+ end
723
+
724
+ class TupleProtocolTestStruct
725
+ include ::Thrift::Struct, ::Thrift::Struct_Union
726
+ FIELD1 = -1
727
+ FIELD2 = -2
728
+ FIELD3 = -3
729
+ FIELD4 = -4
730
+ FIELD5 = -5
731
+ FIELD6 = -6
732
+ FIELD7 = -7
733
+ FIELD8 = -8
734
+ FIELD9 = -9
735
+ FIELD10 = -10
736
+ FIELD11 = -11
737
+ FIELD12 = -12
738
+
739
+ FIELDS = {
740
+ FIELD1 => {:type => ::Thrift::Types::I32, :name => 'field1', :optional => true},
741
+ FIELD2 => {:type => ::Thrift::Types::I32, :name => 'field2', :optional => true},
742
+ FIELD3 => {:type => ::Thrift::Types::I32, :name => 'field3', :optional => true},
743
+ FIELD4 => {:type => ::Thrift::Types::I32, :name => 'field4', :optional => true},
744
+ FIELD5 => {:type => ::Thrift::Types::I32, :name => 'field5', :optional => true},
745
+ FIELD6 => {:type => ::Thrift::Types::I32, :name => 'field6', :optional => true},
746
+ FIELD7 => {:type => ::Thrift::Types::I32, :name => 'field7', :optional => true},
747
+ FIELD8 => {:type => ::Thrift::Types::I32, :name => 'field8', :optional => true},
748
+ FIELD9 => {:type => ::Thrift::Types::I32, :name => 'field9', :optional => true},
749
+ FIELD10 => {:type => ::Thrift::Types::I32, :name => 'field10', :optional => true},
750
+ FIELD11 => {:type => ::Thrift::Types::I32, :name => 'field11', :optional => true},
751
+ FIELD12 => {:type => ::Thrift::Types::I32, :name => 'field12', :optional => true}
752
+ }
753
+
754
+ def struct_fields; FIELDS; end
755
+
756
+ def validate
757
+ end
758
+
759
+ ::Thrift::Struct.generate_accessors self
760
+ end
761
+