ffi-value 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ffi-value.gemspec +1 -1
- data/lib/ffi-value.rb +54 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 642d80f3177db30bb7b0edc8b11e40db7724753ef580fbb4ecc329fd6fdf70bd
|
4
|
+
data.tar.gz: 6162c5c9ad16273bad288edd041e7c889b508da08191cec630e36cba44700c78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 328019333d87b32f242659853318a90b1182a8a25e48c10dffc6b2bf09959cc094429f58108d3ac9e4fe33bbbe62245f3a7b7c05af0ffa9a4c3823b55cd3bc14
|
7
|
+
data.tar.gz: 20476297df0b8e5404f0e545ac832c4ee38a98aeeff23bfb6159d51b1532db8306660bd19b520860edcdf2f054821449a9d32f2f164c10829e0877cb9232f684
|
data/ffi-value.gemspec
CHANGED
data/lib/ffi-value.rb
CHANGED
@@ -23,4 +23,58 @@ module FFI
|
|
23
23
|
end
|
24
24
|
|
25
25
|
typedef m, :value
|
26
|
+
|
27
|
+
class AbstractMemory
|
28
|
+
if FFI::Type::POINTER.size == 8
|
29
|
+
def put_value(offset, value)
|
30
|
+
put_uint64(offset, value.object_id)
|
31
|
+
end
|
32
|
+
def write_value(value)
|
33
|
+
write_uint64(value.object_id)
|
34
|
+
end
|
35
|
+
def put_array_of_value(offset, ary)
|
36
|
+
put_array_of_uint64(offset, ary.collect(&:object_id))
|
37
|
+
end
|
38
|
+
def write_array_of_value(ary)
|
39
|
+
write_array_of_uint64(ary.collect(&:object_id))
|
40
|
+
end
|
41
|
+
def get_value(offset)
|
42
|
+
ObjectSpace._id2ref(get_uint64(offset))
|
43
|
+
end
|
44
|
+
def read_value
|
45
|
+
ObjectSpace._id2ref(read_uint64)
|
46
|
+
end
|
47
|
+
def get_array_of_value(offset, length)
|
48
|
+
get_array_of_uint64(offset, length).collect { |v| ObjectSpace._id2ref(v) }
|
49
|
+
end
|
50
|
+
def read_array_of_value(length)
|
51
|
+
read_array_of_uint64(length).collect { |v| ObjectSpace._id2ref(v) }
|
52
|
+
end
|
53
|
+
else
|
54
|
+
def put_value(offset, value)
|
55
|
+
put_uint32(offset, value.object_id)
|
56
|
+
end
|
57
|
+
def write_value(value)
|
58
|
+
write_uint32(value.object_id)
|
59
|
+
end
|
60
|
+
def put_array_of_value(offset, ary)
|
61
|
+
put_array_of_uint32(offset, ary.collect(&:object_id))
|
62
|
+
end
|
63
|
+
def write_array_of_value(ary)
|
64
|
+
write_array_of_uint32(ary.collect(&:object_id))
|
65
|
+
end
|
66
|
+
def get_value(offset)
|
67
|
+
ObjectSpace._id2ref(get_uint32(offset))
|
68
|
+
end
|
69
|
+
def read_value
|
70
|
+
ObjectSpace._id2ref(read_uint32)
|
71
|
+
end
|
72
|
+
def get_array_of_value(offset, length)
|
73
|
+
get_array_of_uint32(offset, length).collect { |v| ObjectSpace._id2ref(v) }
|
74
|
+
end
|
75
|
+
def read_array_of_value(length)
|
76
|
+
read_array_of_uint32(length).collect { |v| ObjectSpace._id2ref(v) }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
26
80
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-value
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brice Videau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
58
|
- !ruby/object:Gem::Version
|
59
59
|
version: '0'
|
60
60
|
requirements: []
|
61
|
-
rubygems_version: 3.
|
61
|
+
rubygems_version: 3.3.5
|
62
62
|
signing_key:
|
63
63
|
specification_version: 4
|
64
64
|
summary: Allow passing ruby values instead of void* pointers
|