ffi-additions 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -3
- data/lib/ffi-additions/array.rb +11 -0
- data/lib/ffi-additions/struct.rb +11 -1
- data/lib/ffi-additions/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a068fa44cd053f530bf24ad5f84c720271f1289
|
4
|
+
data.tar.gz: 8f8d85c6aa510ef5b1a2118ad76938d9fb7ec5ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4b8ff9380fd82d299a1451481171579865cf39c4a155af32fa659a9ee66cb35754399e91fa5baa0a16ca8c2efc465b360f15e964f51364eb9f42d401a4a3f1f
|
7
|
+
data.tar.gz: f36a2b0acd0fcf5db9b1cc0b3c12559dfb9f44a173c538ef15ba6961dbeaf3cab46b10785d8cbfe4ae71adf35bdd0fbf272015a6ca55c354aefff021f6a788bb
|
data/README.md
CHANGED
@@ -10,11 +10,15 @@ To install:
|
|
10
10
|
gem install ffi-additions
|
11
11
|
```
|
12
12
|
|
13
|
-
|
13
|
+
`FFIAdditions::Struct` - same as FFI::Struct, but with getters and setter defined for all layout fields.
|
14
|
+
|
15
|
+
`Array::from_pointer_of` - maps pointer to an array of structs
|
14
16
|
|
17
|
+
# License
|
18
|
+
```
|
15
19
|
(The MIT License)
|
16
20
|
|
17
|
-
Copyright ©
|
21
|
+
Copyright © 2016 Pedro Miranda
|
18
22
|
|
19
23
|
Permission is hereby granted, free of charge, to any person obtaining
|
20
24
|
a copy of this software and associated documentation files (the
|
@@ -33,4 +37,5 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
33
37
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
34
38
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
35
39
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
36
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
40
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
41
|
+
```
|
data/lib/ffi-additions/struct.rb
CHANGED
@@ -3,10 +3,20 @@ require 'ffi-additions'
|
|
3
3
|
module FFIAdditions
|
4
4
|
class Struct < FFI::Struct
|
5
5
|
def self.layout(*args)
|
6
|
-
|
6
|
+
args = args.first.map do |k, v|
|
7
|
+
if v == :string
|
8
|
+
v = :pointer
|
9
|
+
define_method "#{k}=", ->(s){ self[k] = FFI::MemoryPointer.from_string(s) }
|
10
|
+
end
|
11
|
+
[k, v]
|
12
|
+
end.to_h
|
13
|
+
# puts args
|
14
|
+
super(args)
|
7
15
|
members.each do |name|
|
8
16
|
unless method_defined?(name)
|
9
17
|
define_method name, ->{ self[name] }
|
18
|
+
end
|
19
|
+
unless method_defined?("#{name}=")
|
10
20
|
define_method "#{name}=", ->(v){ self[name] = v }
|
11
21
|
end
|
12
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-additions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- P3t3rU5
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -33,6 +33,7 @@ extra_rdoc_files: []
|
|
33
33
|
files:
|
34
34
|
- README.md
|
35
35
|
- lib/ffi-additions.rb
|
36
|
+
- lib/ffi-additions/array.rb
|
36
37
|
- lib/ffi-additions/struct.rb
|
37
38
|
- lib/ffi-additions/version.rb
|
38
39
|
homepage: https://github.com/P3t3rU5/ffi-additions
|
@@ -55,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
56
|
version: '0'
|
56
57
|
requirements: []
|
57
58
|
rubyforge_project:
|
58
|
-
rubygems_version: 2.6.
|
59
|
+
rubygems_version: 2.6.8
|
59
60
|
signing_key:
|
60
61
|
specification_version: 4
|
61
62
|
summary: Additions to FFI gem
|