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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/ffi-value.gemspec +1 -1
  3. data/lib/ffi-value.rb +54 -0
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba462cc571b1688ec0c40092ae929513e50b29ef3c2fd2766384a40c31c0c2af
4
- data.tar.gz: 3ef162c8ef18f5f90db587d5e3fdff9698593de0d6d727f710b38407fe5ffe31
3
+ metadata.gz: 642d80f3177db30bb7b0edc8b11e40db7724753ef580fbb4ecc329fd6fdf70bd
4
+ data.tar.gz: 6162c5c9ad16273bad288edd041e7c889b508da08191cec630e36cba44700c78
5
5
  SHA512:
6
- metadata.gz: 3005a3c566436ebaacd2fd6dac7de6b9e087726450327d4cc0880d98d7e8bcf7ec096c619902480846102f3e9db2749f9519a6841ed3a3f1fcebc6b4108087b5
7
- data.tar.gz: 89a225c9368934bdfbf539a19341c02e9b9067b11b4cf4eb93211bcd9d5626e3103bcc2aff0caaf3c80277c0a443c0895b3fdef3d00e339c3f9e52e513e7a26e
6
+ metadata.gz: 328019333d87b32f242659853318a90b1182a8a25e48c10dffc6b2bf09959cc094429f58108d3ac9e4fe33bbbe62245f3a7b7c05af0ffa9a4c3823b55cd3bc14
7
+ data.tar.gz: 20476297df0b8e5404f0e545ac832c4ee38a98aeeff23bfb6159d51b1532db8306660bd19b520860edcdf2f054821449a9d32f2f164c10829e0877cb9232f684
data/ffi-value.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'ffi-value'
3
- s.version = "0.1.0"
3
+ s.version = "0.1.1"
4
4
  s.author = "Brice Videau"
5
5
  s.email = "bvideau@anl.gov"
6
6
  s.homepage = "https://github.com/alcf-perfengr/ffi-value"
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.0
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: 2020-12-10 00:00:00.000000000 Z
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.1.2
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