ffi-bitfield 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +38 -9
- data/lib/ffi/bit_field/property.rb +1 -1
- data/lib/ffi/bit_field/version.rb +1 -1
- metadata +3 -73
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e82e912397a405df792824503984be18325c6c22b76307a0fc9d7fe65c5a95f
|
4
|
+
data.tar.gz: a3bbf7a5ecdcba6e4627c80e9a108788e281fc18f9d4abededf5d47833b0783d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76c80c9d0444042ad7ca1b8c28b084562c84b9ac843f0f23a3253444fefee3f4a959da752395d4fa43fc663aab4b1854bb5bd3e21b2550fca2b5c4cc8560ad4a
|
7
|
+
data.tar.gz: 33b72012820da5d15fcf1f753cd2a1203c3bd467b0d4596b429e7c46ba485bee91d45424142c4411996545054eb8f3bd368d53fa477cf7bde330c680689a9276
|
data/README.md
CHANGED
@@ -13,9 +13,21 @@ gem install ffi-bitfield
|
|
13
13
|
|
14
14
|
## Usage
|
15
15
|
|
16
|
+
Classes
|
17
|
+
|
18
|
+
* class BitStruct < FFI::Struct
|
19
|
+
* class ManagedBitStruct < FFI::ManagedStruct
|
20
|
+
|
21
|
+
Loading
|
22
|
+
|
16
23
|
```ruby
|
17
24
|
require 'ffi/bit_struct'
|
25
|
+
require 'ffi/managed_bit_struct'
|
26
|
+
```
|
27
|
+
|
28
|
+
Define your struct
|
18
29
|
|
30
|
+
```ruby
|
19
31
|
class Struct1 < FFI::BitStruct
|
20
32
|
layout \
|
21
33
|
:a, :uint8,
|
@@ -29,10 +41,14 @@ class Struct1 < FFI::BitStruct
|
|
29
41
|
:y, 1,
|
30
42
|
:z, 1
|
31
43
|
end
|
44
|
+
```
|
45
|
+
|
46
|
+
Reading
|
32
47
|
|
48
|
+
```ruby
|
33
49
|
s = Struct1.new
|
34
|
-
s[:a] = 63
|
35
50
|
|
51
|
+
s[:a] = 63
|
36
52
|
p s[:u] # 3
|
37
53
|
p s[:v] # 3
|
38
54
|
p s[:w] # 1
|
@@ -41,6 +57,19 @@ p s[:y] # 0
|
|
41
57
|
p s[:z] # 0
|
42
58
|
```
|
43
59
|
|
60
|
+
Writing
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
s = Struct1.new
|
64
|
+
|
65
|
+
s[:u] = 0
|
66
|
+
s[:v] = 0
|
67
|
+
s[:w] = 0
|
68
|
+
s[:x] = 0
|
69
|
+
s[:y] = 1
|
70
|
+
p s[:a] # 64
|
71
|
+
```
|
72
|
+
|
44
73
|
### Loading
|
45
74
|
|
46
75
|
```ruby
|
@@ -54,14 +83,6 @@ require 'ffi/bit_struct'
|
|
54
83
|
require 'ffi/managed_bit_struct'
|
55
84
|
```
|
56
85
|
|
57
|
-
## API Overview
|
58
|
-
|
59
|
-
```md
|
60
|
-
* module FFI
|
61
|
-
* class BitStruct < FFI::Struct
|
62
|
-
* class ManagedBitStruct < FFI::ManagedStruct
|
63
|
-
```
|
64
|
-
|
65
86
|
## Development
|
66
87
|
|
67
88
|
```
|
@@ -71,11 +92,19 @@ bundle install
|
|
71
92
|
bundle exec rake test
|
72
93
|
```
|
73
94
|
|
95
|
+
* [ffi-bitfield - read/write bit fields with Ruby-FFI](https://dev.to/kojix2/ffi-bitfield-g4h)
|
96
|
+
|
74
97
|
## Contributing
|
75
98
|
|
99
|
+
Your feedback is important.
|
100
|
+
|
76
101
|
ffi-bitfield is a library under development, so even small improvements like typofix are welcome! Please feel free to send us your pull requests.
|
77
102
|
Bug reports and pull requests are welcome on GitHub at https://github.com/kojix2/bitstruct.
|
78
103
|
|
104
|
+
Do you need commit rights to my repository?
|
105
|
+
Do you want to get admin rights and take over the project?
|
106
|
+
If so, please feel free to contact me @kojix2.
|
107
|
+
|
79
108
|
## License
|
80
109
|
|
81
110
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -19,7 +19,7 @@ module FFI
|
|
19
19
|
def []=(member_name, value)
|
20
20
|
parent_name, start, width = member_value_info(member_name)
|
21
21
|
if parent_name
|
22
|
-
raise "Value #{value} is larger than bit_length: #{width}" if value.bit_length > width
|
22
|
+
raise ArgumentError, "Value #{value} is larger than bit_length: #{width}" if value.bit_length > width
|
23
23
|
|
24
24
|
parent_value = get_member_value(parent_name)
|
25
25
|
new_value = (((1 << width) - 1 << start) & parent_value ^ parent_value) |
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-bitfield
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kojix2
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -24,76 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bundler
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: irb
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: minitest
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rake
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rubocop
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
27
|
description: bit fields for Ruby-FFI
|
98
28
|
email:
|
99
29
|
- 2xijok@gmail.com
|
@@ -128,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
58
|
- !ruby/object:Gem::Version
|
129
59
|
version: '0'
|
130
60
|
requirements: []
|
131
|
-
rubygems_version: 3.
|
61
|
+
rubygems_version: 3.3.7
|
132
62
|
signing_key:
|
133
63
|
specification_version: 4
|
134
64
|
summary: bit fields for Ruby-FFI
|