bindata 2.4.8 → 2.4.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.rdoc +9 -0
- data/bindata.gemspec +1 -1
- data/examples/list.rb +1 -1
- data/lib/bindata/alignment.rb +1 -1
- data/lib/bindata/bits.rb +5 -5
- data/lib/bindata/int.rb +10 -8
- data/lib/bindata/io.rb +3 -3
- data/lib/bindata/stringz.rb +1 -1
- data/lib/bindata/version.rb +1 -1
- data/test/bits_test.rb +2 -2
- data/test/delayed_io_test.rb +3 -3
- data/test/int_test.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 651bb61168cb520dbec6550dc4ee3d566e950a0a4e3c373752a37d9ced6dc17e
|
4
|
+
data.tar.gz: 543f3849f0502255c976520e3d11f2e988f0733314b905d098b8617025ef2d99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ab4ddc205727d64b5b4f1354c6c738965745ff6736030f440c3982799351e68af06c9f1e0faff28d6e52830a0abf55d678a0ea7ffefa160f9f7bf3c309b6e7b
|
7
|
+
data.tar.gz: 834bdfa27436e578043e8b92ded99a02e6fc5ca2d0e11f0503bf3d8d68c1c7c9e491e66fe59f264156fb9675437cc9f014193f42132a8e6aec3a11b6f84f5312
|
data/ChangeLog.rdoc
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
= BinData Changelog
|
2
2
|
|
3
|
+
== Version 2.4.10 (2021-05-18)
|
4
|
+
|
5
|
+
* Improve speed of dynamic object creation. Reported by Charlie Ablett.
|
6
|
+
|
7
|
+
== Version 2.4.9 (2021-04-22)
|
8
|
+
|
9
|
+
* Change example from Fixnum to Integer. Thanks to Tim Chambers.
|
10
|
+
* Now works with frozen string literals. Requested by Jeremy Evans.
|
11
|
+
|
3
12
|
== Version 2.4.8 (2020-07-21)
|
4
13
|
|
5
14
|
* Bug fix array self assignment. Thanks to Spencer McIntyre.
|
data/bindata.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.summary = 'A declarative way to read and write binary file formats'
|
9
9
|
s.author = 'Dion Mendel'
|
10
10
|
s.email = 'bindata@dm9.info'
|
11
|
-
s.homepage = '
|
11
|
+
s.homepage = 'https://github.com/dmendel/bindata'
|
12
12
|
s.require_path = 'lib'
|
13
13
|
s.extra_rdoc_files = ['NEWS.rdoc']
|
14
14
|
s.rdoc_options << '--main' << 'NEWS.rdoc'
|
data/examples/list.rb
CHANGED
data/lib/bindata/alignment.rb
CHANGED
data/lib/bindata/bits.rb
CHANGED
@@ -115,14 +115,14 @@ module BinData
|
|
115
115
|
end
|
116
116
|
|
117
117
|
if signed == :signed
|
118
|
-
max = (1 << (nbits - 1)) - 1
|
119
|
-
min = -(max + 1)
|
118
|
+
max = "max = (1 << (#{nbits} - 1)) - 1"
|
119
|
+
min = "min = -(max + 1)"
|
120
120
|
else
|
121
|
-
min = 0
|
122
|
-
max = (1 << nbits) - 1
|
121
|
+
min = "min = 0"
|
122
|
+
max = "max = (1 << #{nbits}) - 1"
|
123
123
|
end
|
124
124
|
|
125
|
-
clamp = "(val <
|
125
|
+
clamp = "(#{max}; #{min}; val = (val < min) ? min : (val > max) ? max : val)"
|
126
126
|
|
127
127
|
if nbits == 1
|
128
128
|
# allow single bits to be used as booleans
|
data/lib/bindata/int.rb
CHANGED
@@ -59,14 +59,16 @@ module BinData
|
|
59
59
|
|
60
60
|
def create_clamp_code(nbits, signed)
|
61
61
|
if signed == :signed
|
62
|
-
max = (1 << (nbits - 1)) - 1
|
63
|
-
min = -(max + 1)
|
62
|
+
max = "max = (1 << (#{nbits} - 1)) - 1"
|
63
|
+
min = "min = -(max + 1)"
|
64
64
|
else
|
65
|
-
max = (1 << nbits) - 1
|
66
|
-
min = 0
|
65
|
+
max = "max = (1 << #{nbits}) - 1"
|
66
|
+
min = "min = 0"
|
67
67
|
end
|
68
68
|
|
69
|
-
"val = (val <
|
69
|
+
clamp = "(#{max}; #{min}; val = (val < min) ? min : (val > max) ? max : val)"
|
70
|
+
|
71
|
+
"val = #{clamp}"
|
70
72
|
end
|
71
73
|
|
72
74
|
def create_read_code(nbits, endian, signed)
|
@@ -107,7 +109,7 @@ module BinData
|
|
107
109
|
parts = (0...nwords).collect do |i|
|
108
110
|
"(ints.at(#{idx[i]}) << #{bits_per_word(nbits) * i})"
|
109
111
|
end
|
110
|
-
parts[0].sub
|
112
|
+
parts[0] = parts[0].sub(/ << 0\b/, "") # Remove " << 0" for optimisation
|
111
113
|
|
112
114
|
parts.join(" + ")
|
113
115
|
end
|
@@ -132,7 +134,7 @@ module BinData
|
|
132
134
|
mask = (1 << bits_per_word(nbits)) - 1
|
133
135
|
|
134
136
|
vals = (0...nwords).collect { |i| "val >> #{bits_per_word(nbits) * i}" }
|
135
|
-
vals[0].sub
|
137
|
+
vals[0] = vals[0].sub(/ >> 0\b/, "") # Remove " >> 0" for optimisation
|
136
138
|
vals.reverse! if (endian == :big)
|
137
139
|
|
138
140
|
vals = vals.collect { |val| "#{val} & #{mask}" } # TODO: "& mask" is needed to work around jruby bug. Remove this line when fixed.
|
@@ -160,7 +162,7 @@ module BinData
|
|
160
162
|
directives = { 8 => "C", 16 => "S", 32 => "L", 64 => "Q" }
|
161
163
|
|
162
164
|
d = directives[bits_per_word(nbits)]
|
163
|
-
d
|
165
|
+
d += ((endian == :big) ? ">" : "<") unless d == "C"
|
164
166
|
|
165
167
|
if signed == :signed && directives.key?(nbits)
|
166
168
|
(d * nwords).downcase
|
data/lib/bindata/io.rb
CHANGED
@@ -169,7 +169,7 @@ module BinData
|
|
169
169
|
|
170
170
|
unless @read_data.empty? || @in_readahead
|
171
171
|
bytes_to_consume = [n, @read_data.length].min
|
172
|
-
data
|
172
|
+
data += @read_data.slice!(0, bytes_to_consume)
|
173
173
|
n -= bytes_to_consume
|
174
174
|
|
175
175
|
if @read_data.empty?
|
@@ -180,10 +180,10 @@ module BinData
|
|
180
180
|
end
|
181
181
|
|
182
182
|
raw_data = @raw_io.read(n)
|
183
|
-
data
|
183
|
+
data += raw_data if raw_data
|
184
184
|
|
185
185
|
if @in_readahead
|
186
|
-
@read_data
|
186
|
+
@read_data += data
|
187
187
|
end
|
188
188
|
|
189
189
|
@offset += data.size
|
data/lib/bindata/stringz.rb
CHANGED
data/lib/bindata/version.rb
CHANGED
data/test/bits_test.rb
CHANGED
@@ -101,14 +101,14 @@ def generate_bit_classes_to_test(endian, signed)
|
|
101
101
|
|
102
102
|
(start .. 64).each do |nbits|
|
103
103
|
name = "#{base}#{nbits}"
|
104
|
-
name
|
104
|
+
name += "le" if endian == :little
|
105
105
|
obj = BinData.const_get(name).new
|
106
106
|
bits << [obj, nbits]
|
107
107
|
end
|
108
108
|
|
109
109
|
(start .. 64).each do |nbits|
|
110
110
|
name = "#{base}"
|
111
|
-
name
|
111
|
+
name += "Le" if endian == :little
|
112
112
|
obj = BinData.const_get(name).new(nbits: nbits)
|
113
113
|
bits << [obj, nbits]
|
114
114
|
end
|
data/test/delayed_io_test.rb
CHANGED
@@ -99,7 +99,7 @@ describe BinData::DelayedIO, "subclassed with a single type" do
|
|
99
99
|
end
|
100
100
|
|
101
101
|
it "writes explicitly" do
|
102
|
-
io = StringIO.new "\001\002\003\004\005\006\007\010\011"
|
102
|
+
io = StringIO.new "\001\002\003\004\005\006\007\010\011".dup
|
103
103
|
obj = IntDelayedIO.new(3)
|
104
104
|
obj.write(io)
|
105
105
|
obj.write_now!
|
@@ -107,7 +107,7 @@ describe BinData::DelayedIO, "subclassed with a single type" do
|
|
107
107
|
end
|
108
108
|
|
109
109
|
it "writes explicitly after setting abs_offset" do
|
110
|
-
io = StringIO.new "\001\002\003\004\005\006\007\010\011"
|
110
|
+
io = StringIO.new "\001\002\003\004\005\006\007\010\011".dup
|
111
111
|
obj = IntDelayedIO.new(7)
|
112
112
|
obj.write(io)
|
113
113
|
|
@@ -139,7 +139,7 @@ describe BinData::DelayedIO, "subclassed with multiple types" do
|
|
139
139
|
end
|
140
140
|
|
141
141
|
it "writes explicitly" do
|
142
|
-
io = StringIO.new "\001\002\003\004\005\006\007\010\011\012\013\014\015"
|
142
|
+
io = StringIO.new "\001\002\003\004\005\006\007\010\011\012\013\014\015".dup
|
143
143
|
obj = StringDelayedIO.new(str: "hello")
|
144
144
|
obj.write(io)
|
145
145
|
obj.write_now!
|
data/test/int_test.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bindata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dion Mendel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -149,7 +149,7 @@ files:
|
|
149
149
|
- test/uint8_array_test.rb
|
150
150
|
- test/virtual_test.rb
|
151
151
|
- test/warnings_test.rb
|
152
|
-
homepage:
|
152
|
+
homepage: https://github.com/dmendel/bindata
|
153
153
|
licenses:
|
154
154
|
- Ruby
|
155
155
|
metadata: {}
|
@@ -170,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
170
|
- !ruby/object:Gem::Version
|
171
171
|
version: '0'
|
172
172
|
requirements: []
|
173
|
-
rubygems_version: 3.1.
|
173
|
+
rubygems_version: 3.1.4
|
174
174
|
signing_key:
|
175
175
|
specification_version: 4
|
176
176
|
summary: A declarative way to read and write binary file formats
|