bindata 3.0.0 → 3.0.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e50992a28fe499f3fc0c25e376060609a6f89abfa391973296601c3e81692c9f
4
- data.tar.gz: 5822008067da279c8e6bb5787a1b720b2a3a563ff60826c543409686ca1a188b
3
+ metadata.gz: b670424a13b7123595397994e787cd02b104b20f845b825711585415c96a1431
4
+ data.tar.gz: cd5c8045b0e11b0e1a4aedac7187431ca3e3b496b15da69a39aa8cfb30b0ae60
5
5
  SHA512:
6
- metadata.gz: 1335d582aae17320deefc138b14ef101dbf6b02e8272a30b1c1e9e5eed935678e4fe6c4d7e55f99eb8cf7ab65b3c9f05b2b77bfcc95520a2e6da09455801569a
7
- data.tar.gz: 95b9d293bc50ee2c7438bd60488725ab4711f3ef25ab6826c86e4b5937af588fc349ce73984d8b9cfe0919999046c8001b028c03bfcbb5a87918bbf0f16a6d7b
6
+ metadata.gz: ce3c150c5a502320e0a8240478d87a923b3e70b48ff1861d4fdd1ef2508a6fc54c6c1f4f3bbd401efc6cf5ad948591141c14c8ad3b8326af118c3b86ad8b192f
7
+ data.tar.gz: a1f12321b82972f9adf2afda0363b8b2d4be504f24b02855015bf9d49e072b4031112bb1149145a4d02e663207bf4e2c62d6b7cf6c199ee54e7b11e56e0af350
data/ChangeLog.rdoc CHANGED
@@ -1,5 +1,9 @@
1
1
  = BinData Changelog
2
2
 
3
+ == Version 3.0.1 (2026-09-27)
4
+
5
+ * Fixed regression with anon classes. Thanks to Babar Al-Amin.
6
+
3
7
  == Version 3.0.0 (2026-07-13)
4
8
 
5
9
  * Ruby 2.x now has its own separate branch.
data/NEWS.rdoc CHANGED
@@ -11,25 +11,26 @@ method.
11
11
  == 2.5.x
12
12
 
13
13
  class Ns1Foo << BinData::Record; end
14
- class Ns1Bar << BinData::Record; end
14
+
15
15
  class Ns2Foo << BinData::Record; end
16
+ class Ns2Bar << BinData::Record; end
16
17
 
17
18
  class MyClass < BinData::Record
18
19
  search_prefix ns2
19
- foo :a # resolves to ns2_foo
20
- bar :b # resolves to ns1_bar
21
- ns1_foo :c # explicitly ns1_foo
20
+ foo :a # resolves to ns2_foo
21
+ bar :b # resolves to ns2_bar
22
+ ns1_foo :c # explicitly ns1_foo
22
23
  end
23
24
 
24
25
  == 3.0.0
25
26
 
26
27
  module Ns1
27
28
  class Foo << BinData::Record; end
28
- class Bar << BinData::Record; end
29
29
  end
30
30
 
31
31
  module Ns2
32
32
  class Foo << BinData::Record; end
33
+ class Bar << BinData::Record; end
33
34
  end
34
35
 
35
36
  module Ns2
@@ -44,8 +45,8 @@ method.
44
45
 
45
46
  class MyClass < BinData::Record
46
47
  search_namespace :ns2
47
- foo :a
48
- bar :b
48
+ foo :a
49
+ bar :b
49
50
  ns1_foo :c
50
51
  end
51
52
 
data/bindata.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  end
19
19
  end
20
20
  s.license = 'BSD-2-Clause'
21
- s.required_ruby_version = ">= 2.5.0"
21
+ s.required_ruby_version = ">= 3.0.0"
22
22
 
23
23
  s.add_development_dependency('rake')
24
24
  s.add_development_dependency('minitest', "~> 5.0")
data/lib/bindata/base.rb CHANGED
@@ -57,7 +57,7 @@ module BinData
57
57
  define_singleton_method(:inherited) do |subclass|
58
58
  m = /(.*)::([^:].*)/.match(subclass.name)
59
59
  namespace = m ? m[1] : ""
60
- shortname = m ? m[2] : subclass
60
+ shortname = m ? m[2] : subclass.name
61
61
  RegisteredClasses.register(namespace, shortname, subclass)
62
62
  register_subclasses
63
63
  end
@@ -93,15 +93,15 @@ module BinData
93
93
  child.respond_to?(symbol, include_all) || super
94
94
  end
95
95
 
96
- def method_missing(symbol, *args, **kwargs, &block) # :nodoc:
96
+ def method_missing(symbol, ...) # :nodoc:
97
97
  child = snapshot
98
98
  if child.respond_to?(symbol)
99
99
  self.class.class_eval <<-END, __FILE__, __LINE__ + 1
100
- def #{symbol}(*args, **kwargs, &block) # def clamp(*args, **kwargs, &block)
101
- snapshot.#{symbol}(*args, **kwargs, &block) # snapshot.clamp(*args, **kwargs, &block)
102
- end # end
100
+ def #{symbol}(...) # def clamp(...)
101
+ snapshot.#{symbol}(...) # snapshot.clamp(...)
102
+ end # end
103
103
  END
104
- child.__send__(symbol, *args, **kwargs, &block)
104
+ child.__send__(symbol, ...)
105
105
  else
106
106
  super
107
107
  end
@@ -84,8 +84,8 @@ module BinData
84
84
  @type.respond_to?(symbol, include_all) || super
85
85
  end
86
86
 
87
- def method_missing(symbol, *args, **kwargs, &block) # :nodoc:
88
- @type.__send__(symbol, *args, **kwargs, &block)
87
+ def method_missing(...) # :nodoc:
88
+ @type.__send__(...)
89
89
  end
90
90
 
91
91
  def do_read(io) # :nodoc:
@@ -90,8 +90,8 @@ module BinData
90
90
  current_choice.respond_to?(symbol, include_all) || super
91
91
  end
92
92
 
93
- def method_missing(symbol, *args, **kwargs, &block) # :nodoc:
94
- current_choice.__send__(symbol, *args, **kwargs, &block)
93
+ def method_missing(...) # :nodoc:
94
+ current_choice.__send__(...)
95
95
  end
96
96
 
97
97
  %w[clear? assign snapshot do_read do_write do_num_bytes].each do |m|
@@ -87,8 +87,8 @@ module BinData
87
87
  @type.respond_to?(symbol, include_all) || super
88
88
  end
89
89
 
90
- def method_missing(symbol, *args, **kwargs, &block) # :nodoc:
91
- @type.__send__(symbol, *args, **kwargs, &block)
90
+ def method_missing(...) # :nodoc:
91
+ @type.__send__(...)
92
92
  end
93
93
 
94
94
  def abs_offset
data/lib/bindata/dsl.rb CHANGED
@@ -42,8 +42,8 @@ module BinData
42
42
  end
43
43
  end
44
44
 
45
- def method_missing(symbol, *args, **kwargs, &block) # :nodoc:
46
- dsl_parser.__send__(symbol, *args, **kwargs, &block)
45
+ def method_missing(...) # :nodoc:
46
+ dsl_parser.__send__(...)
47
47
  end
48
48
 
49
49
  # Assert object is not an array or string.
@@ -134,9 +134,9 @@ module BinData
134
134
  send(abilities.at(0), abilities.at(1))
135
135
  end
136
136
 
137
- def method_missing(*args, **kwargs, &block)
137
+ def method_missing(...)
138
138
  ensure_hints
139
- parse_and_append_field(*args, **kwargs, &block)
139
+ parse_and_append_field(...)
140
140
  end
141
141
 
142
142
  #-------------
data/lib/bindata/int.rb CHANGED
@@ -72,9 +72,17 @@ module BinData
72
72
  end
73
73
 
74
74
  def create_raw_read_code(nbits, endian, signed)
75
- # special case 8bit integers for speed
75
+ nwords = nbits / bits_per_word(nbits)
76
+
76
77
  if nbits == 8
78
+ # faster code for 8bit integers
77
79
  "io.readbytes(1).ord"
80
+ elsif nwords == 1
81
+ # avoid transient arrays for 16, 32 and 64 bit integers
82
+ nbytes = nbits / 8
83
+ pack_directive = pack_directive(nbits, endian, signed)
84
+
85
+ "io.readbytes(#{nbytes}).unpack1('#{pack_directive}')"
78
86
  else
79
87
  unpack_str = create_read_unpack_code(nbits, endian, signed)
80
88
  assemble_str = create_read_assemble_code(nbits, endian)
data/lib/bindata/lazy.rb CHANGED
@@ -62,11 +62,11 @@ module BinData
62
62
  raise NoMethodError, "no index found"
63
63
  end
64
64
 
65
- def method_missing(symbol, *args, **kwargs)
65
+ def method_missing(symbol, ...)
66
66
  return @overrides[symbol] if defined?(@overrides) && @overrides.key?(symbol)
67
67
 
68
68
  if @obj.parent
69
- eval_symbol_in_parent_context(symbol, args, kwargs)
69
+ eval_symbol_in_parent_context(symbol, ...)
70
70
  else
71
71
  super
72
72
  end
@@ -75,26 +75,26 @@ module BinData
75
75
  #---------------
76
76
  private
77
77
 
78
- def eval_symbol_in_parent_context(symbol, args, kwargs)
79
- result = resolve_symbol_in_parent_context(symbol, args, kwargs)
80
- recursively_eval(result, args, kwargs)
78
+ def eval_symbol_in_parent_context(symbol, ...)
79
+ result = resolve_symbol_in_parent_context(symbol, ...)
80
+ recursively_eval(result, ...)
81
81
  end
82
82
 
83
- def resolve_symbol_in_parent_context(symbol, args, kwargs)
83
+ def resolve_symbol_in_parent_context(symbol, ...)
84
84
  obj_parent = @obj.parent
85
85
 
86
86
  if obj_parent.has_parameter?(symbol)
87
87
  obj_parent.get_parameter(symbol)
88
88
  elsif obj_parent.safe_respond_to?(symbol, true)
89
- obj_parent.__send__(symbol, *args, **kwargs)
89
+ obj_parent.__send__(symbol, ...)
90
90
  else
91
91
  symbol
92
92
  end
93
93
  end
94
94
 
95
- def recursively_eval(val, args, kwargs)
95
+ def recursively_eval(val, ...)
96
96
  if val.is_a?(Symbol)
97
- parent.__send__(val, *args, **kwargs)
97
+ parent.__send__(val, ...)
98
98
  elsif callable?(val)
99
99
  parent.instance_exec(&val)
100
100
  else
@@ -77,9 +77,9 @@ module BinData
77
77
  @struct.respond_to?(symbol, include_private) || super
78
78
  end
79
79
 
80
- def method_missing(symbol, *args, **kwargs, &block) # :nodoc:
80
+ def method_missing(symbol, ...) # :nodoc:
81
81
  if @struct.respond_to?(symbol)
82
- @struct.__send__(symbol, *args, **kwargs, &block)
82
+ @struct.__send__(symbol, ...)
83
83
  else
84
84
  super
85
85
  end
@@ -65,8 +65,8 @@ module BinData
65
65
  @type.respond_to?(symbol, include_all) || super
66
66
  end
67
67
 
68
- def method_missing(symbol, *args, **kwargs, &block) # :nodoc:
69
- @type.__send__(symbol, *args, **kwargs, &block)
68
+ def method_missing(...) # :nodoc:
69
+ @type.__send__(...)
70
70
  end
71
71
 
72
72
  def do_read(io) # :nodoc:
@@ -293,7 +293,7 @@ module BinData
293
293
  key?(symbol) || super
294
294
  end
295
295
 
296
- def method_missing(symbol, *args, **kwargs)
296
+ def method_missing(symbol, ...)
297
297
  key?(symbol) ? self[symbol] : super
298
298
  end
299
299
  end
@@ -1,3 +1,3 @@
1
1
  module BinData
2
- VERSION = '3.0.0'
2
+ VERSION = '3.0.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bindata
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dion Mendel
@@ -159,7 +159,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
159
159
  requirements:
160
160
  - - ">="
161
161
  - !ruby/object:Gem::Version
162
- version: 2.5.0
162
+ version: 3.0.0
163
163
  required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  requirements:
165
165
  - - ">="