ffi 1.12.2 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.appveyor.yml +3 -0
  3. data/.github/workflows/ci.yml +64 -0
  4. data/.travis.yml +19 -5
  5. data/CHANGELOG.md +30 -0
  6. data/Gemfile +4 -2
  7. data/Rakefile +24 -43
  8. data/ext/ffi_c/Buffer.c +2 -2
  9. data/ext/ffi_c/Call.c +1 -7
  10. data/ext/ffi_c/ClosurePool.c +11 -14
  11. data/ext/ffi_c/Function.c +8 -23
  12. data/ext/ffi_c/FunctionInfo.c +1 -2
  13. data/ext/ffi_c/LongDouble.c +5 -3
  14. data/ext/ffi_c/LongDouble.h +0 -4
  15. data/ext/ffi_c/MemoryPointer.c +1 -1
  16. data/ext/ffi_c/MethodHandle.c +18 -24
  17. data/ext/ffi_c/MethodHandle.h +3 -2
  18. data/ext/ffi_c/Platform.c +1 -0
  19. data/ext/ffi_c/Pointer.c +1 -1
  20. data/ext/ffi_c/StructLayout.c +7 -2
  21. data/ext/ffi_c/Thread.c +0 -3
  22. data/ext/ffi_c/Thread.h +0 -3
  23. data/ext/ffi_c/compat.h +4 -0
  24. data/ext/ffi_c/extconf.rb +13 -15
  25. data/ext/ffi_c/libffi/.travis.yml +4 -0
  26. data/ext/ffi_c/libffi/.travis/build.sh +4 -0
  27. data/ext/ffi_c/libffi/Makefile.am +2 -1
  28. data/ext/ffi_c/libffi/README.md +7 -1
  29. data/ext/ffi_c/libffi/configure.ac +25 -9
  30. data/ext/ffi_c/libffi/include/ffi.h.in +8 -0
  31. data/ext/ffi_c/libffi/libffi.map.in +8 -12
  32. data/ext/ffi_c/libffi/libtool-version +1 -1
  33. data/ext/ffi_c/libffi/src/aarch64/ffi.c +6 -0
  34. data/ext/ffi_c/libffi/src/aarch64/sysv.S +13 -2
  35. data/ext/ffi_c/libffi/src/closures.c +10 -4
  36. data/ext/ffi_c/libffi/src/pa/ffi.c +46 -91
  37. data/ext/ffi_c/libffi/src/pa/ffitarget.h +1 -6
  38. data/ext/ffi_c/libffi/src/pa/hpux32.S +4 -2
  39. data/ext/ffi_c/libffi/src/pa/linux.S +4 -2
  40. data/ext/ffi_c/libffi/src/powerpc/sysv.S +5 -7
  41. data/ext/ffi_c/libffi/src/x86/ffi.c +7 -4
  42. data/ext/ffi_c/libffi/src/x86/ffi64.c +10 -8
  43. data/ext/ffi_c/libffi/src/x86/ffitarget.h +15 -2
  44. data/ext/ffi_c/libffi/src/x86/ffiw64.c +10 -8
  45. data/ext/ffi_c/libffi/src/x86/sysv.S +13 -4
  46. data/ext/ffi_c/libffi/src/x86/unix64.S +58 -2
  47. data/ext/ffi_c/libffi/src/x86/win64.S +4 -1
  48. data/ffi.gemspec +1 -1
  49. data/lib/ffi.rb +10 -2
  50. data/lib/ffi/library.rb +5 -1
  51. data/lib/ffi/platform.rb +2 -2
  52. data/lib/ffi/platform/arm-linux/types.conf +32 -4
  53. data/lib/ffi/platform/i386-windows/types.conf +26 -79
  54. data/lib/ffi/platform/powerpc-linux/types.conf +32 -2
  55. data/lib/ffi/platform/powerpc-openbsd/types.conf +156 -0
  56. data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
  57. data/lib/ffi/platform/x86_64-darwin/types.conf +4 -0
  58. data/lib/ffi/platform/x86_64-linux/types.conf +21 -0
  59. data/lib/ffi/platform/x86_64-windows/types.conf +10 -78
  60. data/lib/ffi/pointer.rb +19 -12
  61. data/lib/ffi/struct.rb +8 -2
  62. data/lib/ffi/tools/types_generator.rb +2 -0
  63. data/lib/ffi/version.rb +1 -1
  64. data/samples/getlogin.rb +1 -1
  65. data/samples/getpid.rb +1 -1
  66. data/samples/gettimeofday.rb +8 -8
  67. data/samples/hello.rb +2 -1
  68. data/samples/inotify.rb +1 -1
  69. data/samples/pty.rb +1 -2
  70. data/samples/qsort.rb +0 -1
  71. metadata +6 -4
  72. data/samples/sample_helper.rb +0 -6
@@ -228,7 +228,11 @@ module FFI
228
228
 
229
229
  def callback(params, ret)
230
230
  mod = enclosing_module
231
- FFI::CallbackInfo.new(find_type(ret, mod), params.map { |e| find_type(e, mod) })
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
- (mod < FFI::Library || mod < FFI::Struct || mod.respond_to?(:find_type)) ? mod : nil
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
@@ -47,6 +47,8 @@ module FFI
47
47
  typedefs = nil
48
48
  Tempfile.open 'ffi_types_generator' do |io|
49
49
  io.puts <<-C
50
+ #include <stdint.h>
51
+ #include <stddef.h>
50
52
  #include <sys/types.h>
51
53
  #if !(defined(WIN32))
52
54
  #include <sys/socket.h>
@@ -1,3 +1,3 @@
1
1
  module FFI
2
- VERSION = '1.12.2'
2
+ VERSION = '1.13.0'
3
3
  end
@@ -1,5 +1,5 @@
1
- require 'rubygems'
2
1
  require 'ffi'
2
+
3
3
  module Foo
4
4
  extend FFI::Library
5
5
  ffi_lib FFI::Library::LIBC
@@ -1,5 +1,5 @@
1
- require 'rubygems'
2
1
  require 'ffi'
2
+
3
3
  module Foo
4
4
  extend FFI::Library
5
5
  ffi_lib FFI::Library::LIBC
@@ -1,16 +1,16 @@
1
- require 'rubygems'
2
1
  require 'ffi'
2
+ require 'rbconfig'
3
+
3
4
  class Timeval < FFI::Struct
4
- rb_maj, rb_min, rb_micro = RUBY_VERSION.split('.')
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
- ffi_lib FFI::Library::LIBC
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
@@ -1,4 +1,5 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), "sample_helper"))
1
+ require 'ffi'
2
+
2
3
  module Foo
3
4
  extend FFI::Library
4
5
  ffi_lib FFI::Library::LIBC
@@ -1,5 +1,5 @@
1
- require 'rubygems'
2
1
  require 'ffi'
2
+
3
3
  module Inotify
4
4
  extend FFI::Library
5
5
  ffi_lib FFI::Library::LIBC
@@ -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
@@ -1,4 +1,3 @@
1
- require 'rubygems'
2
1
  require 'ffi'
3
2
 
4
3
  module LibC
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.12.2
4
+ version: 1.13.0
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-02-01 00:00:00.000000000 Z
11
+ date: 2020-06-01 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.0'
672
+ version: '2.3'
671
673
  required_rubygems_version: !ruby/object:Gem::Requirement
672
674
  requirements:
673
675
  - - ">="
@@ -1,6 +0,0 @@
1
- require 'rubygems'
2
- require 'spec'
3
-
4
- $:.unshift File.join(File.dirname(__FILE__), "..", "lib"), File.join(File.dirname(__FILE__), "..", "build", RUBY_VERSION) unless RUBY_PLATFORM =~ /java/
5
- require "ffi"
6
-