ffi 1.16.2-x86-mingw32 → 1.16.3-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +1 -1
- data/lib/2.5/ffi_c.so +0 -0
- data/lib/2.6/ffi_c.so +0 -0
- data/lib/2.7/ffi_c.so +0 -0
- data/lib/3.0/ffi_c.so +0 -0
- data/lib/3.1/ffi_c.so +0 -0
- data/lib/3.2/ffi_c.so +0 -0
- data/lib/ffi/types.rb +2 -1
- data/lib/ffi/version.rb +1 -1
- data/samples/hello_ractor.rb +11 -0
- data/samples/qsort_ractor.rb +28 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c26131103c98ca311ea502fb789ba427a6547e95ab726f3a90f6ee40c83edd4
|
4
|
+
data.tar.gz: bce1cdedd649f045d5a7324a0aca02a8d77db28a3777b60d4cf8792fa1d53367
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a644762a862ca08d225837cfdd12e4950b07ee8d06afd636058682e7c7a761f761ee683eb3a95f152215f8d73de4a116d971f2cad1475c9169a4f8786157005a
|
7
|
+
data.tar.gz: f17e732e2f84b1dacdfb8757776a512e28bc703aff21100914b0386f90f634e49c09e36e05371acfa63a4d222f54414e6a8220b0b2e870f44560f4493469e2a3
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -15,7 +15,7 @@ using Ruby-FFI](https://github.com/ffi/ffi/wiki/why-use-ffi).
|
|
15
15
|
* C structs (also nested), enums and global variables
|
16
16
|
* Callbacks from C to Ruby
|
17
17
|
* Automatic garbage collection of native memory
|
18
|
-
* Usable in Ractor
|
18
|
+
* Usable in Ractor: [How-to-use-FFI-in-Ruby-Ractors](https://github.com/ffi/ffi/wiki/Ractors)
|
19
19
|
|
20
20
|
## Synopsis
|
21
21
|
|
data/lib/2.5/ffi_c.so
CHANGED
Binary file
|
data/lib/2.6/ffi_c.so
CHANGED
Binary file
|
data/lib/2.7/ffi_c.so
CHANGED
Binary file
|
data/lib/3.0/ffi_c.so
CHANGED
Binary file
|
data/lib/3.1/ffi_c.so
CHANGED
Binary file
|
data/lib/3.2/ffi_c.so
CHANGED
Binary file
|
data/lib/ffi/types.rb
CHANGED
@@ -87,7 +87,8 @@ module FFI
|
|
87
87
|
TypeDefs[name]
|
88
88
|
|
89
89
|
elsif name.is_a?(DataConverter)
|
90
|
-
(type_map ||
|
90
|
+
tm = (type_map || custom_typedefs)
|
91
|
+
tm[name] = Type::Mapped.new(name)
|
91
92
|
else
|
92
93
|
raise TypeError, "unable to resolve type '#{name}'"
|
93
94
|
end
|
data/lib/ffi/version.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
|
3
|
+
module LibC
|
4
|
+
extend FFI::Library
|
5
|
+
ffi_lib FFI::Library::LIBC
|
6
|
+
callback :qsort_cmp, [ :pointer, :pointer ], :int
|
7
|
+
attach_function :qsort, [ :pointer, :ulong, :ulong, :qsort_cmp ], :int
|
8
|
+
|
9
|
+
freeze # Freeze the module variables, so that it can be shared across ractors.
|
10
|
+
end
|
11
|
+
|
12
|
+
p = FFI::MemoryPointer.new(:int, 3)
|
13
|
+
p.put_array_of_int32(0, [ 2, 3, 1 ]) # Write some unsorted data into the memory
|
14
|
+
# Ractor.make_shareable(p) # freeze the pointer to be shared between ractors instead of copied
|
15
|
+
puts "main -ptr=#{p.inspect}"
|
16
|
+
res = Ractor.new(p) do |p|
|
17
|
+
puts "ractor-ptr=#{p.inspect}"
|
18
|
+
puts "Before qsort #{p.get_array_of_int32(0, 3).join(', ')}"
|
19
|
+
LibC.qsort(p, 3, 4) do |p1, p2|
|
20
|
+
i1 = p1.get_int32(0)
|
21
|
+
i2 = p2.get_int32(0)
|
22
|
+
puts "In block: comparing #{i1} and #{i2}"
|
23
|
+
i1 < i2 ? -1 : i1 > i2 ? 1 : 0
|
24
|
+
end
|
25
|
+
puts "After qsort #{p.get_array_of_int32(0, 3).join(', ')}"
|
26
|
+
end.take
|
27
|
+
|
28
|
+
puts "After ractor termination #{p.get_array_of_int32(0, 3).join(', ')}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.16.
|
4
|
+
version: 1.16.3
|
5
5
|
platform: x86-mingw32
|
6
6
|
authors:
|
7
7
|
- Wayne Meissner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -181,9 +181,11 @@ files:
|
|
181
181
|
- samples/getpid.rb
|
182
182
|
- samples/gettimeofday.rb
|
183
183
|
- samples/hello.rb
|
184
|
+
- samples/hello_ractor.rb
|
184
185
|
- samples/inotify.rb
|
185
186
|
- samples/pty.rb
|
186
187
|
- samples/qsort.rb
|
188
|
+
- samples/qsort_ractor.rb
|
187
189
|
homepage: https://github.com/ffi/ffi/wiki
|
188
190
|
licenses:
|
189
191
|
- BSD-3-Clause
|