ffi 1.12.1 → 1.13.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) 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 +47 -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/Struct.c +47 -51
  21. data/ext/ffi_c/Struct.h +12 -6
  22. data/ext/ffi_c/StructLayout.c +20 -14
  23. data/ext/ffi_c/Thread.c +0 -3
  24. data/ext/ffi_c/Thread.h +0 -3
  25. data/ext/ffi_c/compat.h +4 -0
  26. data/ext/ffi_c/extconf.rb +16 -20
  27. data/ext/ffi_c/libffi/.travis.yml +4 -0
  28. data/ext/ffi_c/libffi/.travis/build.sh +4 -0
  29. data/ext/ffi_c/libffi/Makefile.am +2 -1
  30. data/ext/ffi_c/libffi/README.md +7 -1
  31. data/ext/ffi_c/libffi/configure.ac +25 -9
  32. data/ext/ffi_c/libffi/include/ffi.h.in +8 -0
  33. data/ext/ffi_c/libffi/libffi.map.in +8 -12
  34. data/ext/ffi_c/libffi/libtool-version +1 -1
  35. data/ext/ffi_c/libffi/src/aarch64/ffi.c +6 -0
  36. data/ext/ffi_c/libffi/src/aarch64/sysv.S +13 -2
  37. data/ext/ffi_c/libffi/src/closures.c +10 -4
  38. data/ext/ffi_c/libffi/src/pa/ffi.c +46 -91
  39. data/ext/ffi_c/libffi/src/pa/ffitarget.h +1 -6
  40. data/ext/ffi_c/libffi/src/pa/hpux32.S +4 -2
  41. data/ext/ffi_c/libffi/src/pa/linux.S +4 -2
  42. data/ext/ffi_c/libffi/src/powerpc/sysv.S +5 -7
  43. data/ext/ffi_c/libffi/src/x86/ffi.c +7 -4
  44. data/ext/ffi_c/libffi/src/x86/ffi64.c +10 -8
  45. data/ext/ffi_c/libffi/src/x86/ffitarget.h +15 -2
  46. data/ext/ffi_c/libffi/src/x86/ffiw64.c +10 -8
  47. data/ext/ffi_c/libffi/src/x86/sysv.S +13 -4
  48. data/ext/ffi_c/libffi/src/x86/unix64.S +58 -2
  49. data/ext/ffi_c/libffi/src/x86/win64.S +4 -1
  50. data/ffi.gemspec +1 -1
  51. data/lib/ffi.rb +10 -2
  52. data/lib/ffi/library.rb +5 -1
  53. data/lib/ffi/platform.rb +6 -2
  54. data/lib/ffi/platform/arm-linux/types.conf +32 -4
  55. data/lib/ffi/platform/i386-windows/types.conf +26 -79
  56. data/lib/ffi/platform/powerpc-linux/types.conf +32 -2
  57. data/lib/ffi/platform/powerpc-openbsd/types.conf +156 -0
  58. data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
  59. data/lib/ffi/platform/x86_64-darwin/types.conf +4 -0
  60. data/lib/ffi/platform/x86_64-dragonflybsd/types.conf +4 -22
  61. data/lib/ffi/platform/x86_64-linux/types.conf +21 -0
  62. data/lib/ffi/platform/x86_64-windows/types.conf +10 -78
  63. data/lib/ffi/pointer.rb +19 -12
  64. data/lib/ffi/struct.rb +9 -4
  65. data/lib/ffi/tools/types_generator.rb +2 -0
  66. data/lib/ffi/version.rb +1 -1
  67. data/samples/getlogin.rb +1 -1
  68. data/samples/getpid.rb +1 -1
  69. data/samples/gettimeofday.rb +8 -8
  70. data/samples/hello.rb +2 -1
  71. data/samples/inotify.rb +1 -1
  72. data/samples/pty.rb +1 -2
  73. data/samples/qsort.rb +0 -1
  74. metadata +6 -4
  75. data/samples/sample_helper.rb +0 -6
@@ -190,7 +190,7 @@ module FFI
190
190
  # :field2, :pointer, 6, # set offset to 6 for this field
191
191
  # :field3, :string
192
192
  # end
193
- # @example Creating a layout from a hash +spec+ (Ruby 1.9 only)
193
+ # @example Creating a layout from a hash +spec+
194
194
  # class MyStructFromHash < Struct
195
195
  # layout :field1 => :int,
196
196
  # :field2 => :pointer,
@@ -202,7 +202,6 @@ module FFI
202
202
  # :function2, callback([:pointer], :void),
203
203
  # :field3, :string
204
204
  # end
205
- # @note Creating a layout from a hash +spec+ is supported only for Ruby 1.9.
206
205
  def layout(*spec)
207
206
  warn "[DEPRECATION] Struct layout is already defined for class #{self.inspect}. Redefinition as in #{caller[0]} will be disallowed in ffi-2.0." if defined?(@layout)
208
207
  return @layout if spec.size == 0
@@ -229,7 +228,11 @@ module FFI
229
228
 
230
229
  def callback(params, ret)
231
230
  mod = enclosing_module
232
- 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) })
233
236
  end
234
237
 
235
238
  def packed(packed = 1)
@@ -245,7 +248,9 @@ module FFI
245
248
  def enclosing_module
246
249
  begin
247
250
  mod = self.name.split("::")[0..-2].inject(Object) { |obj, c| obj.const_get(c) }
248
- (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
249
254
  rescue Exception
250
255
  nil
251
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.1'
2
+ VERSION = '1.13.1'
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.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-01-14 00:00:00.000000000 Z
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.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
-