ffi 1.12.2 → 1.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.appveyor.yml +3 -0
- data/.github/workflows/ci.yml +64 -0
- data/.travis.yml +19 -5
- data/CHANGELOG.md +41 -0
- data/Gemfile +4 -2
- data/Rakefile +24 -43
- data/ext/ffi_c/Buffer.c +2 -2
- data/ext/ffi_c/Call.c +1 -7
- data/ext/ffi_c/ClosurePool.c +11 -14
- data/ext/ffi_c/Function.c +8 -23
- data/ext/ffi_c/FunctionInfo.c +1 -2
- data/ext/ffi_c/LongDouble.c +5 -3
- data/ext/ffi_c/LongDouble.h +0 -4
- data/ext/ffi_c/MemoryPointer.c +1 -1
- data/ext/ffi_c/MethodHandle.c +18 -24
- data/ext/ffi_c/MethodHandle.h +3 -2
- data/ext/ffi_c/Platform.c +1 -0
- data/ext/ffi_c/Pointer.c +1 -1
- data/ext/ffi_c/StructLayout.c +7 -2
- data/ext/ffi_c/Thread.c +0 -3
- data/ext/ffi_c/Thread.h +0 -3
- data/ext/ffi_c/compat.h +4 -0
- data/ext/ffi_c/extconf.rb +16 -19
- data/ext/ffi_c/libffi/.travis.yml +4 -0
- data/ext/ffi_c/libffi/.travis/build.sh +4 -0
- data/ext/ffi_c/libffi/Makefile.am +2 -1
- data/ext/ffi_c/libffi/README.md +7 -1
- data/ext/ffi_c/libffi/configure.ac +25 -9
- data/ext/ffi_c/libffi/include/ffi.h.in +8 -0
- data/ext/ffi_c/libffi/libffi.map.in +8 -12
- data/ext/ffi_c/libffi/libtool-version +1 -1
- data/ext/ffi_c/libffi/src/aarch64/ffi.c +6 -0
- data/ext/ffi_c/libffi/src/aarch64/sysv.S +13 -2
- data/ext/ffi_c/libffi/src/closures.c +10 -4
- data/ext/ffi_c/libffi/src/pa/ffi.c +46 -91
- data/ext/ffi_c/libffi/src/pa/ffitarget.h +1 -6
- data/ext/ffi_c/libffi/src/pa/hpux32.S +4 -2
- data/ext/ffi_c/libffi/src/pa/linux.S +4 -2
- data/ext/ffi_c/libffi/src/powerpc/sysv.S +5 -7
- data/ext/ffi_c/libffi/src/x86/ffi.c +7 -4
- data/ext/ffi_c/libffi/src/x86/ffi64.c +10 -8
- data/ext/ffi_c/libffi/src/x86/ffitarget.h +15 -2
- data/ext/ffi_c/libffi/src/x86/ffiw64.c +10 -8
- data/ext/ffi_c/libffi/src/x86/sysv.S +13 -4
- data/ext/ffi_c/libffi/src/x86/unix64.S +58 -2
- data/ext/ffi_c/libffi/src/x86/win64.S +4 -1
- data/ffi.gemspec +1 -1
- data/lib/ffi.rb +10 -2
- data/lib/ffi/library.rb +5 -1
- data/lib/ffi/platform.rb +6 -2
- data/lib/ffi/platform/arm-linux/types.conf +32 -4
- data/lib/ffi/platform/i386-windows/types.conf +26 -79
- data/lib/ffi/platform/powerpc-linux/types.conf +32 -2
- data/lib/ffi/platform/powerpc-openbsd/types.conf +156 -0
- data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
- data/lib/ffi/platform/x86_64-darwin/types.conf +4 -0
- data/lib/ffi/platform/x86_64-dragonflybsd/types.conf +4 -22
- data/lib/ffi/platform/x86_64-linux/types.conf +21 -0
- data/lib/ffi/platform/x86_64-windows/types.conf +10 -78
- data/lib/ffi/pointer.rb +19 -12
- data/lib/ffi/struct.rb +8 -2
- data/lib/ffi/tools/types_generator.rb +2 -0
- data/lib/ffi/version.rb +1 -1
- data/samples/getlogin.rb +1 -1
- data/samples/getpid.rb +1 -1
- data/samples/gettimeofday.rb +8 -8
- data/samples/hello.rb +2 -1
- data/samples/inotify.rb +1 -1
- data/samples/pty.rb +1 -2
- data/samples/qsort.rb +0 -1
- metadata +6 -4
- data/samples/sample_helper.rb +0 -6
data/lib/ffi/struct.rb
CHANGED
@@ -228,7 +228,11 @@ module FFI
|
|
228
228
|
|
229
229
|
def callback(params, ret)
|
230
230
|
mod = enclosing_module
|
231
|
-
|
231
|
+
ret_type = find_type(ret, mod)
|
232
|
+
if ret_type == Type::STRING
|
233
|
+
raise TypeError, ":string is not allowed as return type of callbacks"
|
234
|
+
end
|
235
|
+
FFI::CallbackInfo.new(ret_type, params.map { |e| find_type(e, mod) })
|
232
236
|
end
|
233
237
|
|
234
238
|
def packed(packed = 1)
|
@@ -244,7 +248,9 @@ module FFI
|
|
244
248
|
def enclosing_module
|
245
249
|
begin
|
246
250
|
mod = self.name.split("::")[0..-2].inject(Object) { |obj, c| obj.const_get(c) }
|
247
|
-
(
|
251
|
+
if mod.respond_to?(:find_type) && (mod.is_a?(FFI::Library) || mod < FFI::Struct)
|
252
|
+
mod
|
253
|
+
end
|
248
254
|
rescue Exception
|
249
255
|
nil
|
250
256
|
end
|
data/lib/ffi/version.rb
CHANGED
data/samples/getlogin.rb
CHANGED
data/samples/getpid.rb
CHANGED
data/samples/gettimeofday.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
require 'ffi'
|
2
|
+
require 'rbconfig'
|
3
|
+
|
3
4
|
class Timeval < FFI::Struct
|
4
|
-
|
5
|
-
if rb_maj.to_i >= 1 && rb_min.to_i >= 9 || RUBY_PLATFORM =~ /java/
|
6
|
-
layout :tv_sec => :ulong, :tv_usec => :ulong
|
7
|
-
else
|
8
|
-
layout :tv_sec, :ulong, 0, :tv_usec, :ulong, 4
|
9
|
-
end
|
5
|
+
layout tv_sec: :ulong, tv_usec: :ulong
|
10
6
|
end
|
11
7
|
module LibC
|
12
8
|
extend FFI::Library
|
13
|
-
|
9
|
+
if FFI::Platform.windows?
|
10
|
+
ffi_lib RbConfig::CONFIG["LIBRUBY_SO"]
|
11
|
+
else
|
12
|
+
ffi_lib FFI::Library::LIBC
|
13
|
+
end
|
14
14
|
attach_function :gettimeofday, [ :pointer, :pointer ], :int
|
15
15
|
end
|
16
16
|
t = Timeval.new
|
data/samples/hello.rb
CHANGED
data/samples/inotify.rb
CHANGED
data/samples/pty.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'ffi'
|
2
2
|
|
3
|
-
|
4
3
|
module PTY
|
5
4
|
private
|
6
5
|
module LibC
|
@@ -41,7 +40,7 @@ module PTY
|
|
41
40
|
#
|
42
41
|
exec_cmd, exec_args = build_args(args)
|
43
42
|
pid = LibC.forkpty(mfdp, name, nil, nil)
|
44
|
-
raise "forkpty failed: #{LibC.strerror(FFI.errno)}" if pid < 0
|
43
|
+
raise "forkpty failed: #{LibC.strerror(FFI.errno)}" if pid < 0
|
45
44
|
if pid == 0
|
46
45
|
LibC.execvp(exec_cmd, exec_args)
|
47
46
|
exit 1
|
data/samples/qsort.rb
CHANGED
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.
|
4
|
+
version: 1.13.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wayne Meissner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -88,6 +88,7 @@ extensions:
|
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
90
|
- ".appveyor.yml"
|
91
|
+
- ".github/workflows/ci.yml"
|
91
92
|
- ".gitignore"
|
92
93
|
- ".gitmodules"
|
93
94
|
- ".travis.yml"
|
@@ -608,12 +609,14 @@ files:
|
|
608
609
|
- lib/ffi/platform/powerpc-aix/types.conf
|
609
610
|
- lib/ffi/platform/powerpc-darwin/types.conf
|
610
611
|
- lib/ffi/platform/powerpc-linux/types.conf
|
612
|
+
- lib/ffi/platform/powerpc-openbsd/types.conf
|
611
613
|
- lib/ffi/platform/powerpc64-linux/types.conf
|
612
614
|
- lib/ffi/platform/s390-linux/types.conf
|
613
615
|
- lib/ffi/platform/s390x-linux/types.conf
|
614
616
|
- lib/ffi/platform/sparc-linux/types.conf
|
615
617
|
- lib/ffi/platform/sparc-solaris/types.conf
|
616
618
|
- lib/ffi/platform/sparc64-linux/types.conf
|
619
|
+
- lib/ffi/platform/sparcv9-openbsd/types.conf
|
617
620
|
- lib/ffi/platform/sparcv9-solaris/types.conf
|
618
621
|
- lib/ffi/platform/x86_64-cygwin/types.conf
|
619
622
|
- lib/ffi/platform/x86_64-darwin/types.conf
|
@@ -646,7 +649,6 @@ files:
|
|
646
649
|
- samples/inotify.rb
|
647
650
|
- samples/pty.rb
|
648
651
|
- samples/qsort.rb
|
649
|
-
- samples/sample_helper.rb
|
650
652
|
homepage: https://github.com/ffi/ffi/wiki
|
651
653
|
licenses:
|
652
654
|
- BSD-3-Clause
|
@@ -667,7 +669,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
667
669
|
requirements:
|
668
670
|
- - ">="
|
669
671
|
- !ruby/object:Gem::Version
|
670
|
-
version: '2.
|
672
|
+
version: '2.3'
|
671
673
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
672
674
|
requirements:
|
673
675
|
- - ">="
|