ffi-value 0.1.1 → 0.1.3
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 +39 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c44b2c700443f80945a065401279350b867acefdb9296f13cf5e0e73f70562f3
|
4
|
+
data.tar.gz: e373b704c61d10f617fa690b2854fdcf6953439eeb8bf12daa37ba6c4ba95b0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34fc9f3771ea92aa7f8f1eba0d3ec8741f7a8e537303370296e20a2a15f9fa99727ac9024b1666d98c9ad222b687e1ab68ae099d7aabcee8277f8c1157af0a2a
|
7
|
+
data.tar.gz: c0108059385c6bcd071590a3d2e9acae94f74c306b0b1da6a854b99425b5f2e15a992312d404025cbc9c960b58abe020aa3cb276b0cf1c6fcf96e462703e54da
|
data/ffi-value.gemspec
CHANGED
data/lib/ffi-value.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
require 'ffi'
|
2
2
|
|
3
3
|
module FFI
|
4
|
+
ValueStore = Hash.new { |h, k| h[k.object_id] = [k, 0] }
|
5
|
+
ValueStoreMutex = Mutex.new
|
6
|
+
|
4
7
|
m = Module.new do
|
5
8
|
extend FFI::DataConverter
|
6
9
|
if FFI::Type::POINTER.size == 8
|
@@ -22,7 +25,42 @@ module FFI
|
|
22
25
|
end
|
23
26
|
end
|
24
27
|
|
25
|
-
|
28
|
+
if TypeDefs.frozen?
|
29
|
+
t = TypeDefs.dup
|
30
|
+
remove_const(:TypeDefs)
|
31
|
+
const_set(:TypeDefs, t)
|
32
|
+
typedef m, :value
|
33
|
+
TypeDefs.freeze
|
34
|
+
else
|
35
|
+
typedef m, :value
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.inc_ref(object)
|
39
|
+
refcount = nil
|
40
|
+
ValueStoreMutex.synchronize {
|
41
|
+
_, refcount = ValueStore[object.object_id]
|
42
|
+
refcount += 1
|
43
|
+
ValueStore[object.object_id] = [object, refcount]
|
44
|
+
}
|
45
|
+
refcount
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.dec_ref(object)
|
49
|
+
refcount = nil
|
50
|
+
ValueStoreMutex.synchronize {
|
51
|
+
_, refcount = ValueStore[object.object_id]
|
52
|
+
refcount -= 1
|
53
|
+
if (refcount <= 0) then
|
54
|
+
ValueStore.delete(object.object_id)
|
55
|
+
else
|
56
|
+
ValueStore[object.object_id] = [object, refcount]
|
57
|
+
end
|
58
|
+
}
|
59
|
+
if refcount < 0
|
60
|
+
raise ArgumentError.new("Object: #{object.object_id} was not previously referenced!")
|
61
|
+
end
|
62
|
+
refcount
|
63
|
+
end
|
26
64
|
|
27
65
|
class AbstractMemory
|
28
66
|
if FFI::Type::POINTER.size == 8
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brice Videau
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -43,7 +43,7 @@ homepage: https://github.com/alcf-perfengr/ffi-value
|
|
43
43
|
licenses:
|
44
44
|
- BSD-3-Clause
|
45
45
|
metadata: {}
|
46
|
-
post_install_message:
|
46
|
+
post_install_message:
|
47
47
|
rdoc_options: []
|
48
48
|
require_paths:
|
49
49
|
- lib
|
@@ -58,8 +58,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
58
|
- !ruby/object:Gem::Version
|
59
59
|
version: '0'
|
60
60
|
requirements: []
|
61
|
-
rubygems_version: 3.
|
62
|
-
signing_key:
|
61
|
+
rubygems_version: 3.4.20
|
62
|
+
signing_key:
|
63
63
|
specification_version: 4
|
64
64
|
summary: Allow passing ruby values instead of void* pointers
|
65
65
|
test_files: []
|