bindata 0.9.3 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bindata might be problematic. Click here for more details.
- data/ChangeLog +18 -0
- data/NEWS +59 -0
- data/README +22 -23
- data/TODO +18 -12
- data/examples/gzip.rb +4 -4
- data/lib/bindata.rb +4 -3
- data/lib/bindata/array.rb +202 -132
- data/lib/bindata/base.rb +147 -166
- data/lib/bindata/{single.rb → base_primitive.rb} +82 -56
- data/lib/bindata/bits.rb +31 -770
- data/lib/bindata/choice.rb +157 -82
- data/lib/bindata/float.rb +25 -27
- data/lib/bindata/int.rb +144 -177
- data/lib/bindata/io.rb +59 -49
- data/lib/bindata/lazy.rb +80 -50
- data/lib/bindata/params.rb +134 -26
- data/lib/bindata/{single_value.rb → primitive.rb} +71 -64
- data/lib/bindata/{multi_value.rb → record.rb} +52 -70
- data/lib/bindata/registry.rb +49 -17
- data/lib/bindata/rest.rb +6 -10
- data/lib/bindata/sanitize.rb +55 -70
- data/lib/bindata/string.rb +60 -42
- data/lib/bindata/stringz.rb +34 -35
- data/lib/bindata/struct.rb +197 -152
- data/lib/bindata/trace.rb +35 -0
- data/spec/array_spec.rb +128 -112
- data/spec/{single_spec.rb → base_primitive_spec.rb} +102 -61
- data/spec/base_spec.rb +190 -185
- data/spec/bits_spec.rb +126 -98
- data/spec/choice_spec.rb +89 -98
- data/spec/example.rb +19 -0
- data/spec/float_spec.rb +28 -44
- data/spec/int_spec.rb +217 -127
- data/spec/io_spec.rb +41 -24
- data/spec/lazy_spec.rb +95 -49
- data/spec/primitive_spec.rb +191 -0
- data/spec/{multi_value_spec.rb → record_spec.rb} +124 -89
- data/spec/registry_spec.rb +53 -12
- data/spec/rest_spec.rb +2 -3
- data/spec/sanitize_spec.rb +47 -73
- data/spec/spec_common.rb +13 -1
- data/spec/string_spec.rb +34 -23
- data/spec/stringz_spec.rb +10 -18
- data/spec/struct_spec.rb +91 -63
- data/spec/system_spec.rb +291 -0
- metadata +12 -8
- data/spec/single_value_spec.rb +0 -131
data/lib/bindata/bits.rb
CHANGED
@@ -1,11 +1,23 @@
|
|
1
|
-
require 'bindata/
|
1
|
+
require 'bindata/base_primitive'
|
2
2
|
|
3
3
|
module BinData
|
4
|
-
#
|
5
|
-
# is defined by endian
|
4
|
+
# Defines a number of classes that contain a bit based integer.
|
5
|
+
# The integer is defined by endian and number of bits.
|
6
6
|
|
7
7
|
module BitField #:nodoc: all
|
8
|
-
def self.
|
8
|
+
def self.define_class(nbits, endian)
|
9
|
+
name = "Bit#{nbits}"
|
10
|
+
name += "le" if endian == :little
|
11
|
+
|
12
|
+
BinData.module_eval <<-END
|
13
|
+
class #{name} < BinData::BasePrimitive
|
14
|
+
register(self.name, self)
|
15
|
+
BitField.create_methods(self, #{nbits}, :#{endian.to_s})
|
16
|
+
end
|
17
|
+
END
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.create_methods(bit_class, nbits, endian)
|
9
21
|
min = 0
|
10
22
|
max = (1 << nbits) - 1
|
11
23
|
clamp = "val = (val < #{min}) ? #{min} : (val > #{max}) ? #{max} : val"
|
@@ -15,31 +27,30 @@ module BinData
|
|
15
27
|
clamp = "val = (val == true) ? 1 : (not val) ? 0 : #{clamp}"
|
16
28
|
end
|
17
29
|
|
18
|
-
define_methods(
|
30
|
+
define_methods(bit_class, nbits, endian.to_s, clamp)
|
19
31
|
end
|
20
32
|
|
21
|
-
def self.define_methods(
|
22
|
-
|
23
|
-
|
24
|
-
|
33
|
+
def self.define_methods(bit_class, nbits, endian, clamp)
|
34
|
+
bit_class.module_eval <<-END
|
35
|
+
#---------------
|
36
|
+
private
|
37
|
+
|
38
|
+
def _assign(val)
|
25
39
|
#{clamp}
|
26
40
|
super(val)
|
27
41
|
end
|
28
42
|
|
29
|
-
#---------------
|
30
|
-
private
|
31
|
-
|
32
43
|
def _do_write(io)
|
33
|
-
raise "can't write whilst reading" if @in_read
|
34
|
-
io.writebits(_value, #{nbits},
|
44
|
+
raise "can't write whilst reading \#{debug_name}" if @in_read
|
45
|
+
io.writebits(_value, #{nbits}, :#{endian})
|
35
46
|
end
|
36
47
|
|
37
48
|
def _do_num_bytes(ignored)
|
38
49
|
#{nbits} / 8.0
|
39
50
|
end
|
40
51
|
|
41
|
-
def
|
42
|
-
io.readbits(#{nbits},
|
52
|
+
def read_and_return_value(io)
|
53
|
+
io.readbits(#{nbits}, :#{endian})
|
43
54
|
end
|
44
55
|
|
45
56
|
def sensible_default
|
@@ -49,759 +60,9 @@ module BinData
|
|
49
60
|
end
|
50
61
|
end
|
51
62
|
|
52
|
-
#
|
53
|
-
|
54
|
-
|
55
|
-
BitField.
|
56
|
-
end
|
57
|
-
|
58
|
-
# 1 bit little endian bitfield.
|
59
|
-
class Bit1le < BinData::Single
|
60
|
-
register(self.name, self)
|
61
|
-
BitField.create_methods(self, 1, :little)
|
62
|
-
end
|
63
|
-
|
64
|
-
# 2 bit big endian bitfield.
|
65
|
-
class Bit2 < BinData::Single
|
66
|
-
register(self.name, self)
|
67
|
-
BitField.create_methods(self, 2, :big)
|
68
|
-
end
|
69
|
-
|
70
|
-
# 2 bit little endian bitfield.
|
71
|
-
class Bit2le < BinData::Single
|
72
|
-
register(self.name, self)
|
73
|
-
BitField.create_methods(self, 2, :little)
|
74
|
-
end
|
75
|
-
|
76
|
-
# 3 bit big endian bitfield.
|
77
|
-
class Bit3 < BinData::Single
|
78
|
-
register(self.name, self)
|
79
|
-
BitField.create_methods(self, 3, :big)
|
80
|
-
end
|
81
|
-
|
82
|
-
# 3 bit little endian bitfield.
|
83
|
-
class Bit3le < BinData::Single
|
84
|
-
register(self.name, self)
|
85
|
-
BitField.create_methods(self, 3, :little)
|
86
|
-
end
|
87
|
-
|
88
|
-
# 4 bit big endian bitfield.
|
89
|
-
class Bit4 < BinData::Single
|
90
|
-
register(self.name, self)
|
91
|
-
BitField.create_methods(self, 4, :big)
|
92
|
-
end
|
93
|
-
|
94
|
-
# 4 bit little endian bitfield.
|
95
|
-
class Bit4le < BinData::Single
|
96
|
-
register(self.name, self)
|
97
|
-
BitField.create_methods(self, 4, :little)
|
98
|
-
end
|
99
|
-
|
100
|
-
# 5 bit big endian bitfield.
|
101
|
-
class Bit5 < BinData::Single
|
102
|
-
register(self.name, self)
|
103
|
-
BitField.create_methods(self, 5, :big)
|
104
|
-
end
|
105
|
-
|
106
|
-
# 5 bit little endian bitfield.
|
107
|
-
class Bit5le < BinData::Single
|
108
|
-
register(self.name, self)
|
109
|
-
BitField.create_methods(self, 5, :little)
|
110
|
-
end
|
111
|
-
|
112
|
-
# 6 bit big endian bitfield.
|
113
|
-
class Bit6 < BinData::Single
|
114
|
-
register(self.name, self)
|
115
|
-
BitField.create_methods(self, 6, :big)
|
116
|
-
end
|
117
|
-
|
118
|
-
# 6 bit little endian bitfield.
|
119
|
-
class Bit6le < BinData::Single
|
120
|
-
register(self.name, self)
|
121
|
-
BitField.create_methods(self, 6, :little)
|
122
|
-
end
|
123
|
-
|
124
|
-
# 7 bit big endian bitfield.
|
125
|
-
class Bit7 < BinData::Single
|
126
|
-
register(self.name, self)
|
127
|
-
BitField.create_methods(self, 7, :big)
|
128
|
-
end
|
129
|
-
|
130
|
-
# 7 bit little endian bitfield.
|
131
|
-
class Bit7le < BinData::Single
|
132
|
-
register(self.name, self)
|
133
|
-
BitField.create_methods(self, 7, :little)
|
134
|
-
end
|
135
|
-
|
136
|
-
# 8 bit big endian bitfield.
|
137
|
-
class Bit8 < BinData::Single
|
138
|
-
register(self.name, self)
|
139
|
-
BitField.create_methods(self, 8, :big)
|
140
|
-
end
|
141
|
-
|
142
|
-
# 8 bit little endian bitfield.
|
143
|
-
class Bit8le < BinData::Single
|
144
|
-
register(self.name, self)
|
145
|
-
BitField.create_methods(self, 8, :little)
|
146
|
-
end
|
147
|
-
|
148
|
-
# 9 bit big endian bitfield.
|
149
|
-
class Bit9 < BinData::Single
|
150
|
-
register(self.name, self)
|
151
|
-
BitField.create_methods(self, 9, :big)
|
152
|
-
end
|
153
|
-
|
154
|
-
# 9 bit little endian bitfield.
|
155
|
-
class Bit9le < BinData::Single
|
156
|
-
register(self.name, self)
|
157
|
-
BitField.create_methods(self, 9, :little)
|
158
|
-
end
|
159
|
-
|
160
|
-
# 10 bit big endian bitfield.
|
161
|
-
class Bit10 < BinData::Single
|
162
|
-
register(self.name, self)
|
163
|
-
BitField.create_methods(self, 10, :big)
|
164
|
-
end
|
165
|
-
|
166
|
-
# 10 bit little endian bitfield.
|
167
|
-
class Bit10le < BinData::Single
|
168
|
-
register(self.name, self)
|
169
|
-
BitField.create_methods(self, 10, :little)
|
170
|
-
end
|
171
|
-
|
172
|
-
# 11 bit big endian bitfield.
|
173
|
-
class Bit11 < BinData::Single
|
174
|
-
register(self.name, self)
|
175
|
-
BitField.create_methods(self, 11, :big)
|
176
|
-
end
|
177
|
-
|
178
|
-
# 11 bit little endian bitfield.
|
179
|
-
class Bit11le < BinData::Single
|
180
|
-
register(self.name, self)
|
181
|
-
BitField.create_methods(self, 11, :little)
|
182
|
-
end
|
183
|
-
|
184
|
-
# 12 bit big endian bitfield.
|
185
|
-
class Bit12 < BinData::Single
|
186
|
-
register(self.name, self)
|
187
|
-
BitField.create_methods(self, 12, :big)
|
188
|
-
end
|
189
|
-
|
190
|
-
# 12 bit little endian bitfield.
|
191
|
-
class Bit12le < BinData::Single
|
192
|
-
register(self.name, self)
|
193
|
-
BitField.create_methods(self, 12, :little)
|
194
|
-
end
|
195
|
-
|
196
|
-
# 13 bit big endian bitfield.
|
197
|
-
class Bit13 < BinData::Single
|
198
|
-
register(self.name, self)
|
199
|
-
BitField.create_methods(self, 13, :big)
|
200
|
-
end
|
201
|
-
|
202
|
-
# 13 bit little endian bitfield.
|
203
|
-
class Bit13le < BinData::Single
|
204
|
-
register(self.name, self)
|
205
|
-
BitField.create_methods(self, 13, :little)
|
206
|
-
end
|
207
|
-
|
208
|
-
# 14 bit big endian bitfield.
|
209
|
-
class Bit14 < BinData::Single
|
210
|
-
register(self.name, self)
|
211
|
-
BitField.create_methods(self, 14, :big)
|
212
|
-
end
|
213
|
-
|
214
|
-
# 14 bit little endian bitfield.
|
215
|
-
class Bit14le < BinData::Single
|
216
|
-
register(self.name, self)
|
217
|
-
BitField.create_methods(self, 14, :little)
|
218
|
-
end
|
219
|
-
|
220
|
-
# 15 bit big endian bitfield.
|
221
|
-
class Bit15 < BinData::Single
|
222
|
-
register(self.name, self)
|
223
|
-
BitField.create_methods(self, 15, :big)
|
224
|
-
end
|
225
|
-
|
226
|
-
# 15 bit little endian bitfield.
|
227
|
-
class Bit15le < BinData::Single
|
228
|
-
register(self.name, self)
|
229
|
-
BitField.create_methods(self, 15, :little)
|
230
|
-
end
|
231
|
-
|
232
|
-
# 16 bit big endian bitfield.
|
233
|
-
class Bit16 < BinData::Single
|
234
|
-
register(self.name, self)
|
235
|
-
BitField.create_methods(self, 16, :big)
|
236
|
-
end
|
237
|
-
|
238
|
-
# 16 bit little endian bitfield.
|
239
|
-
class Bit16le < BinData::Single
|
240
|
-
register(self.name, self)
|
241
|
-
BitField.create_methods(self, 16, :little)
|
242
|
-
end
|
243
|
-
|
244
|
-
# 17 bit big endian bitfield.
|
245
|
-
class Bit17 < BinData::Single
|
246
|
-
register(self.name, self)
|
247
|
-
BitField.create_methods(self, 17, :big)
|
248
|
-
end
|
249
|
-
|
250
|
-
# 17 bit little endian bitfield.
|
251
|
-
class Bit17le < BinData::Single
|
252
|
-
register(self.name, self)
|
253
|
-
BitField.create_methods(self, 17, :little)
|
254
|
-
end
|
255
|
-
|
256
|
-
# 18 bit big endian bitfield.
|
257
|
-
class Bit18 < BinData::Single
|
258
|
-
register(self.name, self)
|
259
|
-
BitField.create_methods(self, 18, :big)
|
260
|
-
end
|
261
|
-
|
262
|
-
# 18 bit little endian bitfield.
|
263
|
-
class Bit18le < BinData::Single
|
264
|
-
register(self.name, self)
|
265
|
-
BitField.create_methods(self, 18, :little)
|
266
|
-
end
|
267
|
-
|
268
|
-
# 19 bit big endian bitfield.
|
269
|
-
class Bit19 < BinData::Single
|
270
|
-
register(self.name, self)
|
271
|
-
BitField.create_methods(self, 19, :big)
|
272
|
-
end
|
273
|
-
|
274
|
-
# 19 bit little endian bitfield.
|
275
|
-
class Bit19le < BinData::Single
|
276
|
-
register(self.name, self)
|
277
|
-
BitField.create_methods(self, 19, :little)
|
278
|
-
end
|
279
|
-
|
280
|
-
# 20 bit big endian bitfield.
|
281
|
-
class Bit20 < BinData::Single
|
282
|
-
register(self.name, self)
|
283
|
-
BitField.create_methods(self, 20, :big)
|
284
|
-
end
|
285
|
-
|
286
|
-
# 20 bit little endian bitfield.
|
287
|
-
class Bit20le < BinData::Single
|
288
|
-
register(self.name, self)
|
289
|
-
BitField.create_methods(self, 20, :little)
|
290
|
-
end
|
291
|
-
|
292
|
-
# 21 bit big endian bitfield.
|
293
|
-
class Bit21 < BinData::Single
|
294
|
-
register(self.name, self)
|
295
|
-
BitField.create_methods(self, 21, :big)
|
296
|
-
end
|
297
|
-
|
298
|
-
# 21 bit little endian bitfield.
|
299
|
-
class Bit21le < BinData::Single
|
300
|
-
register(self.name, self)
|
301
|
-
BitField.create_methods(self, 21, :little)
|
302
|
-
end
|
303
|
-
|
304
|
-
# 22 bit big endian bitfield.
|
305
|
-
class Bit22 < BinData::Single
|
306
|
-
register(self.name, self)
|
307
|
-
BitField.create_methods(self, 22, :big)
|
308
|
-
end
|
309
|
-
|
310
|
-
# 22 bit little endian bitfield.
|
311
|
-
class Bit22le < BinData::Single
|
312
|
-
register(self.name, self)
|
313
|
-
BitField.create_methods(self, 22, :little)
|
314
|
-
end
|
315
|
-
|
316
|
-
# 23 bit big endian bitfield.
|
317
|
-
class Bit23 < BinData::Single
|
318
|
-
register(self.name, self)
|
319
|
-
BitField.create_methods(self, 23, :big)
|
320
|
-
end
|
321
|
-
|
322
|
-
# 23 bit little endian bitfield.
|
323
|
-
class Bit23le < BinData::Single
|
324
|
-
register(self.name, self)
|
325
|
-
BitField.create_methods(self, 23, :little)
|
326
|
-
end
|
327
|
-
|
328
|
-
# 24 bit big endian bitfield.
|
329
|
-
class Bit24 < BinData::Single
|
330
|
-
register(self.name, self)
|
331
|
-
BitField.create_methods(self, 24, :big)
|
332
|
-
end
|
333
|
-
|
334
|
-
# 24 bit little endian bitfield.
|
335
|
-
class Bit24le < BinData::Single
|
336
|
-
register(self.name, self)
|
337
|
-
BitField.create_methods(self, 24, :little)
|
338
|
-
end
|
339
|
-
|
340
|
-
# 25 bit big endian bitfield.
|
341
|
-
class Bit25 < BinData::Single
|
342
|
-
register(self.name, self)
|
343
|
-
BitField.create_methods(self, 25, :big)
|
344
|
-
end
|
345
|
-
|
346
|
-
# 25 bit little endian bitfield.
|
347
|
-
class Bit25le < BinData::Single
|
348
|
-
register(self.name, self)
|
349
|
-
BitField.create_methods(self, 25, :little)
|
350
|
-
end
|
351
|
-
|
352
|
-
# 26 bit big endian bitfield.
|
353
|
-
class Bit26 < BinData::Single
|
354
|
-
register(self.name, self)
|
355
|
-
BitField.create_methods(self, 26, :big)
|
356
|
-
end
|
357
|
-
|
358
|
-
# 26 bit little endian bitfield.
|
359
|
-
class Bit26le < BinData::Single
|
360
|
-
register(self.name, self)
|
361
|
-
BitField.create_methods(self, 26, :little)
|
362
|
-
end
|
363
|
-
|
364
|
-
# 27 bit big endian bitfield.
|
365
|
-
class Bit27 < BinData::Single
|
366
|
-
register(self.name, self)
|
367
|
-
BitField.create_methods(self, 27, :big)
|
368
|
-
end
|
369
|
-
|
370
|
-
# 27 bit little endian bitfield.
|
371
|
-
class Bit27le < BinData::Single
|
372
|
-
register(self.name, self)
|
373
|
-
BitField.create_methods(self, 27, :little)
|
374
|
-
end
|
375
|
-
|
376
|
-
# 28 bit big endian bitfield.
|
377
|
-
class Bit28 < BinData::Single
|
378
|
-
register(self.name, self)
|
379
|
-
BitField.create_methods(self, 28, :big)
|
380
|
-
end
|
381
|
-
|
382
|
-
# 28 bit little endian bitfield.
|
383
|
-
class Bit28le < BinData::Single
|
384
|
-
register(self.name, self)
|
385
|
-
BitField.create_methods(self, 28, :little)
|
386
|
-
end
|
387
|
-
|
388
|
-
# 29 bit big endian bitfield.
|
389
|
-
class Bit29 < BinData::Single
|
390
|
-
register(self.name, self)
|
391
|
-
BitField.create_methods(self, 29, :big)
|
392
|
-
end
|
393
|
-
|
394
|
-
# 29 bit little endian bitfield.
|
395
|
-
class Bit29le < BinData::Single
|
396
|
-
register(self.name, self)
|
397
|
-
BitField.create_methods(self, 29, :little)
|
398
|
-
end
|
399
|
-
|
400
|
-
# 30 bit big endian bitfield.
|
401
|
-
class Bit30 < BinData::Single
|
402
|
-
register(self.name, self)
|
403
|
-
BitField.create_methods(self, 30, :big)
|
404
|
-
end
|
405
|
-
|
406
|
-
# 30 bit little endian bitfield.
|
407
|
-
class Bit30le < BinData::Single
|
408
|
-
register(self.name, self)
|
409
|
-
BitField.create_methods(self, 30, :little)
|
410
|
-
end
|
411
|
-
|
412
|
-
# 31 bit big endian bitfield.
|
413
|
-
class Bit31 < BinData::Single
|
414
|
-
register(self.name, self)
|
415
|
-
BitField.create_methods(self, 31, :big)
|
416
|
-
end
|
417
|
-
|
418
|
-
# 31 bit little endian bitfield.
|
419
|
-
class Bit31le < BinData::Single
|
420
|
-
register(self.name, self)
|
421
|
-
BitField.create_methods(self, 31, :little)
|
422
|
-
end
|
423
|
-
|
424
|
-
# 32 bit big endian bitfield.
|
425
|
-
class Bit32 < BinData::Single
|
426
|
-
register(self.name, self)
|
427
|
-
BitField.create_methods(self, 32, :big)
|
428
|
-
end
|
429
|
-
|
430
|
-
# 32 bit little endian bitfield.
|
431
|
-
class Bit32le < BinData::Single
|
432
|
-
register(self.name, self)
|
433
|
-
BitField.create_methods(self, 32, :little)
|
434
|
-
end
|
435
|
-
|
436
|
-
# 33 bit big endian bitfield.
|
437
|
-
class Bit33 < BinData::Single
|
438
|
-
register(self.name, self)
|
439
|
-
BitField.create_methods(self, 33, :big)
|
440
|
-
end
|
441
|
-
|
442
|
-
# 33 bit little endian bitfield.
|
443
|
-
class Bit33le < BinData::Single
|
444
|
-
register(self.name, self)
|
445
|
-
BitField.create_methods(self, 33, :little)
|
446
|
-
end
|
447
|
-
|
448
|
-
# 34 bit big endian bitfield.
|
449
|
-
class Bit34 < BinData::Single
|
450
|
-
register(self.name, self)
|
451
|
-
BitField.create_methods(self, 34, :big)
|
452
|
-
end
|
453
|
-
|
454
|
-
# 34 bit little endian bitfield.
|
455
|
-
class Bit34le < BinData::Single
|
456
|
-
register(self.name, self)
|
457
|
-
BitField.create_methods(self, 34, :little)
|
458
|
-
end
|
459
|
-
|
460
|
-
# 35 bit big endian bitfield.
|
461
|
-
class Bit35 < BinData::Single
|
462
|
-
register(self.name, self)
|
463
|
-
BitField.create_methods(self, 35, :big)
|
464
|
-
end
|
465
|
-
|
466
|
-
# 35 bit little endian bitfield.
|
467
|
-
class Bit35le < BinData::Single
|
468
|
-
register(self.name, self)
|
469
|
-
BitField.create_methods(self, 35, :little)
|
470
|
-
end
|
471
|
-
|
472
|
-
# 36 bit big endian bitfield.
|
473
|
-
class Bit36 < BinData::Single
|
474
|
-
register(self.name, self)
|
475
|
-
BitField.create_methods(self, 36, :big)
|
476
|
-
end
|
477
|
-
|
478
|
-
# 36 bit little endian bitfield.
|
479
|
-
class Bit36le < BinData::Single
|
480
|
-
register(self.name, self)
|
481
|
-
BitField.create_methods(self, 36, :little)
|
482
|
-
end
|
483
|
-
|
484
|
-
# 37 bit big endian bitfield.
|
485
|
-
class Bit37 < BinData::Single
|
486
|
-
register(self.name, self)
|
487
|
-
BitField.create_methods(self, 37, :big)
|
488
|
-
end
|
489
|
-
|
490
|
-
# 37 bit little endian bitfield.
|
491
|
-
class Bit37le < BinData::Single
|
492
|
-
register(self.name, self)
|
493
|
-
BitField.create_methods(self, 37, :little)
|
494
|
-
end
|
495
|
-
|
496
|
-
# 38 bit big endian bitfield.
|
497
|
-
class Bit38 < BinData::Single
|
498
|
-
register(self.name, self)
|
499
|
-
BitField.create_methods(self, 38, :big)
|
500
|
-
end
|
501
|
-
|
502
|
-
# 38 bit little endian bitfield.
|
503
|
-
class Bit38le < BinData::Single
|
504
|
-
register(self.name, self)
|
505
|
-
BitField.create_methods(self, 38, :little)
|
506
|
-
end
|
507
|
-
|
508
|
-
# 39 bit big endian bitfield.
|
509
|
-
class Bit39 < BinData::Single
|
510
|
-
register(self.name, self)
|
511
|
-
BitField.create_methods(self, 39, :big)
|
512
|
-
end
|
513
|
-
|
514
|
-
# 39 bit little endian bitfield.
|
515
|
-
class Bit39le < BinData::Single
|
516
|
-
register(self.name, self)
|
517
|
-
BitField.create_methods(self, 39, :little)
|
518
|
-
end
|
519
|
-
|
520
|
-
# 40 bit big endian bitfield.
|
521
|
-
class Bit40 < BinData::Single
|
522
|
-
register(self.name, self)
|
523
|
-
BitField.create_methods(self, 40, :big)
|
524
|
-
end
|
525
|
-
|
526
|
-
# 40 bit little endian bitfield.
|
527
|
-
class Bit40le < BinData::Single
|
528
|
-
register(self.name, self)
|
529
|
-
BitField.create_methods(self, 40, :little)
|
530
|
-
end
|
531
|
-
|
532
|
-
# 41 bit big endian bitfield.
|
533
|
-
class Bit41 < BinData::Single
|
534
|
-
register(self.name, self)
|
535
|
-
BitField.create_methods(self, 41, :big)
|
536
|
-
end
|
537
|
-
|
538
|
-
# 41 bit little endian bitfield.
|
539
|
-
class Bit41le < BinData::Single
|
540
|
-
register(self.name, self)
|
541
|
-
BitField.create_methods(self, 41, :little)
|
542
|
-
end
|
543
|
-
|
544
|
-
# 42 bit big endian bitfield.
|
545
|
-
class Bit42 < BinData::Single
|
546
|
-
register(self.name, self)
|
547
|
-
BitField.create_methods(self, 42, :big)
|
548
|
-
end
|
549
|
-
|
550
|
-
# 42 bit little endian bitfield.
|
551
|
-
class Bit42le < BinData::Single
|
552
|
-
register(self.name, self)
|
553
|
-
BitField.create_methods(self, 42, :little)
|
554
|
-
end
|
555
|
-
|
556
|
-
# 43 bit big endian bitfield.
|
557
|
-
class Bit43 < BinData::Single
|
558
|
-
register(self.name, self)
|
559
|
-
BitField.create_methods(self, 43, :big)
|
560
|
-
end
|
561
|
-
|
562
|
-
# 43 bit little endian bitfield.
|
563
|
-
class Bit43le < BinData::Single
|
564
|
-
register(self.name, self)
|
565
|
-
BitField.create_methods(self, 43, :little)
|
566
|
-
end
|
567
|
-
|
568
|
-
# 44 bit big endian bitfield.
|
569
|
-
class Bit44 < BinData::Single
|
570
|
-
register(self.name, self)
|
571
|
-
BitField.create_methods(self, 44, :big)
|
572
|
-
end
|
573
|
-
|
574
|
-
# 44 bit little endian bitfield.
|
575
|
-
class Bit44le < BinData::Single
|
576
|
-
register(self.name, self)
|
577
|
-
BitField.create_methods(self, 44, :little)
|
578
|
-
end
|
579
|
-
|
580
|
-
# 45 bit big endian bitfield.
|
581
|
-
class Bit45 < BinData::Single
|
582
|
-
register(self.name, self)
|
583
|
-
BitField.create_methods(self, 45, :big)
|
584
|
-
end
|
585
|
-
|
586
|
-
# 45 bit little endian bitfield.
|
587
|
-
class Bit45le < BinData::Single
|
588
|
-
register(self.name, self)
|
589
|
-
BitField.create_methods(self, 45, :little)
|
590
|
-
end
|
591
|
-
|
592
|
-
# 46 bit big endian bitfield.
|
593
|
-
class Bit46 < BinData::Single
|
594
|
-
register(self.name, self)
|
595
|
-
BitField.create_methods(self, 46, :big)
|
596
|
-
end
|
597
|
-
|
598
|
-
# 46 bit little endian bitfield.
|
599
|
-
class Bit46le < BinData::Single
|
600
|
-
register(self.name, self)
|
601
|
-
BitField.create_methods(self, 46, :little)
|
602
|
-
end
|
603
|
-
|
604
|
-
# 47 bit big endian bitfield.
|
605
|
-
class Bit47 < BinData::Single
|
606
|
-
register(self.name, self)
|
607
|
-
BitField.create_methods(self, 47, :big)
|
608
|
-
end
|
609
|
-
|
610
|
-
# 47 bit little endian bitfield.
|
611
|
-
class Bit47le < BinData::Single
|
612
|
-
register(self.name, self)
|
613
|
-
BitField.create_methods(self, 47, :little)
|
614
|
-
end
|
615
|
-
|
616
|
-
# 48 bit big endian bitfield.
|
617
|
-
class Bit48 < BinData::Single
|
618
|
-
register(self.name, self)
|
619
|
-
BitField.create_methods(self, 48, :big)
|
620
|
-
end
|
621
|
-
|
622
|
-
# 48 bit little endian bitfield.
|
623
|
-
class Bit48le < BinData::Single
|
624
|
-
register(self.name, self)
|
625
|
-
BitField.create_methods(self, 48, :little)
|
626
|
-
end
|
627
|
-
|
628
|
-
# 49 bit big endian bitfield.
|
629
|
-
class Bit49 < BinData::Single
|
630
|
-
register(self.name, self)
|
631
|
-
BitField.create_methods(self, 49, :big)
|
632
|
-
end
|
633
|
-
|
634
|
-
# 49 bit little endian bitfield.
|
635
|
-
class Bit49le < BinData::Single
|
636
|
-
register(self.name, self)
|
637
|
-
BitField.create_methods(self, 49, :little)
|
638
|
-
end
|
639
|
-
|
640
|
-
# 50 bit big endian bitfield.
|
641
|
-
class Bit50 < BinData::Single
|
642
|
-
register(self.name, self)
|
643
|
-
BitField.create_methods(self, 50, :big)
|
644
|
-
end
|
645
|
-
|
646
|
-
# 50 bit little endian bitfield.
|
647
|
-
class Bit50le < BinData::Single
|
648
|
-
register(self.name, self)
|
649
|
-
BitField.create_methods(self, 50, :little)
|
650
|
-
end
|
651
|
-
|
652
|
-
# 51 bit big endian bitfield.
|
653
|
-
class Bit51 < BinData::Single
|
654
|
-
register(self.name, self)
|
655
|
-
BitField.create_methods(self, 51, :big)
|
656
|
-
end
|
657
|
-
|
658
|
-
# 51 bit little endian bitfield.
|
659
|
-
class Bit51le < BinData::Single
|
660
|
-
register(self.name, self)
|
661
|
-
BitField.create_methods(self, 51, :little)
|
662
|
-
end
|
663
|
-
|
664
|
-
# 52 bit big endian bitfield.
|
665
|
-
class Bit52 < BinData::Single
|
666
|
-
register(self.name, self)
|
667
|
-
BitField.create_methods(self, 52, :big)
|
668
|
-
end
|
669
|
-
|
670
|
-
# 52 bit little endian bitfield.
|
671
|
-
class Bit52le < BinData::Single
|
672
|
-
register(self.name, self)
|
673
|
-
BitField.create_methods(self, 52, :little)
|
674
|
-
end
|
675
|
-
|
676
|
-
# 53 bit big endian bitfield.
|
677
|
-
class Bit53 < BinData::Single
|
678
|
-
register(self.name, self)
|
679
|
-
BitField.create_methods(self, 53, :big)
|
680
|
-
end
|
681
|
-
|
682
|
-
# 53 bit little endian bitfield.
|
683
|
-
class Bit53le < BinData::Single
|
684
|
-
register(self.name, self)
|
685
|
-
BitField.create_methods(self, 53, :little)
|
686
|
-
end
|
687
|
-
|
688
|
-
# 54 bit big endian bitfield.
|
689
|
-
class Bit54 < BinData::Single
|
690
|
-
register(self.name, self)
|
691
|
-
BitField.create_methods(self, 54, :big)
|
692
|
-
end
|
693
|
-
|
694
|
-
# 54 bit little endian bitfield.
|
695
|
-
class Bit54le < BinData::Single
|
696
|
-
register(self.name, self)
|
697
|
-
BitField.create_methods(self, 54, :little)
|
698
|
-
end
|
699
|
-
|
700
|
-
# 55 bit big endian bitfield.
|
701
|
-
class Bit55 < BinData::Single
|
702
|
-
register(self.name, self)
|
703
|
-
BitField.create_methods(self, 55, :big)
|
704
|
-
end
|
705
|
-
|
706
|
-
# 55 bit little endian bitfield.
|
707
|
-
class Bit55le < BinData::Single
|
708
|
-
register(self.name, self)
|
709
|
-
BitField.create_methods(self, 55, :little)
|
710
|
-
end
|
711
|
-
|
712
|
-
# 56 bit big endian bitfield.
|
713
|
-
class Bit56 < BinData::Single
|
714
|
-
register(self.name, self)
|
715
|
-
BitField.create_methods(self, 56, :big)
|
716
|
-
end
|
717
|
-
|
718
|
-
# 56 bit little endian bitfield.
|
719
|
-
class Bit56le < BinData::Single
|
720
|
-
register(self.name, self)
|
721
|
-
BitField.create_methods(self, 56, :little)
|
722
|
-
end
|
723
|
-
|
724
|
-
# 57 bit big endian bitfield.
|
725
|
-
class Bit57 < BinData::Single
|
726
|
-
register(self.name, self)
|
727
|
-
BitField.create_methods(self, 57, :big)
|
728
|
-
end
|
729
|
-
|
730
|
-
# 57 bit little endian bitfield.
|
731
|
-
class Bit57le < BinData::Single
|
732
|
-
register(self.name, self)
|
733
|
-
BitField.create_methods(self, 57, :little)
|
734
|
-
end
|
735
|
-
|
736
|
-
# 58 bit big endian bitfield.
|
737
|
-
class Bit58 < BinData::Single
|
738
|
-
register(self.name, self)
|
739
|
-
BitField.create_methods(self, 58, :big)
|
740
|
-
end
|
741
|
-
|
742
|
-
# 58 bit little endian bitfield.
|
743
|
-
class Bit58le < BinData::Single
|
744
|
-
register(self.name, self)
|
745
|
-
BitField.create_methods(self, 58, :little)
|
746
|
-
end
|
747
|
-
|
748
|
-
# 59 bit big endian bitfield.
|
749
|
-
class Bit59 < BinData::Single
|
750
|
-
register(self.name, self)
|
751
|
-
BitField.create_methods(self, 59, :big)
|
752
|
-
end
|
753
|
-
|
754
|
-
# 59 bit little endian bitfield.
|
755
|
-
class Bit59le < BinData::Single
|
756
|
-
register(self.name, self)
|
757
|
-
BitField.create_methods(self, 59, :little)
|
758
|
-
end
|
759
|
-
|
760
|
-
# 60 bit big endian bitfield.
|
761
|
-
class Bit60 < BinData::Single
|
762
|
-
register(self.name, self)
|
763
|
-
BitField.create_methods(self, 60, :big)
|
764
|
-
end
|
765
|
-
|
766
|
-
# 60 bit little endian bitfield.
|
767
|
-
class Bit60le < BinData::Single
|
768
|
-
register(self.name, self)
|
769
|
-
BitField.create_methods(self, 60, :little)
|
770
|
-
end
|
771
|
-
|
772
|
-
# 61 bit big endian bitfield.
|
773
|
-
class Bit61 < BinData::Single
|
774
|
-
register(self.name, self)
|
775
|
-
BitField.create_methods(self, 61, :big)
|
776
|
-
end
|
777
|
-
|
778
|
-
# 61 bit little endian bitfield.
|
779
|
-
class Bit61le < BinData::Single
|
780
|
-
register(self.name, self)
|
781
|
-
BitField.create_methods(self, 61, :little)
|
782
|
-
end
|
783
|
-
|
784
|
-
# 62 bit big endian bitfield.
|
785
|
-
class Bit62 < BinData::Single
|
786
|
-
register(self.name, self)
|
787
|
-
BitField.create_methods(self, 62, :big)
|
788
|
-
end
|
789
|
-
|
790
|
-
# 62 bit little endian bitfield.
|
791
|
-
class Bit62le < BinData::Single
|
792
|
-
register(self.name, self)
|
793
|
-
BitField.create_methods(self, 62, :little)
|
794
|
-
end
|
795
|
-
|
796
|
-
# 63 bit big endian bitfield.
|
797
|
-
class Bit63 < BinData::Single
|
798
|
-
register(self.name, self)
|
799
|
-
BitField.create_methods(self, 63, :big)
|
800
|
-
end
|
801
|
-
|
802
|
-
# 63 bit little endian bitfield.
|
803
|
-
class Bit63le < BinData::Single
|
804
|
-
register(self.name, self)
|
805
|
-
BitField.create_methods(self, 63, :little)
|
63
|
+
# Create commonly used bit based integers
|
64
|
+
(1 .. 63).each do |nbits|
|
65
|
+
BitField.define_class(nbits, :little)
|
66
|
+
BitField.define_class(nbits, :big)
|
806
67
|
end
|
807
68
|
end
|