thrift 0.6.0 → 0.7.0

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