ffi 1.17.2-arm64-darwin → 1.17.3-arm64-darwin

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d6a30828daae75fb595fcdff5e46af863e8b769a2d36910ff99d278b23e1c7b
4
- data.tar.gz: a1bda8cb55b85678881601311ea2c3525d9212c7f380aad69c8dbf3b4f8e0fe9
3
+ metadata.gz: fc6e3eb9231e3194654594e392b06730542b8e3bbc0e80e65b13c2ac5c5f938b
4
+ data.tar.gz: 7c3d235442d3a836e9013a7beea8027565a307080b08ca2c4a6b98246e7b31dc
5
5
  SHA512:
6
- metadata.gz: 165730f75204571632dcc066f854b140710700bb55abd9d25aa1ec5f54ea54b7ea540e60ce7f30279a67f28de97e548bc3b8b4322aef418314111eaf08576b52
7
- data.tar.gz: 4e9888493e6db60a3aaadeb1bc6c2b705595a72140bc59644419ae940f5e8c6f8a8fcdd261302d3f67b01300d46c64c2fad9620420ea252c2ffa2528fb434f75
6
+ metadata.gz: db6e79e726d8b71b0b73f2ee402af343439288b1917cb0bd88a33dba138d8af29613451ff29940fb5ddc11e3eff2617a086da31417d044df05f1d4aec5d45062
7
+ data.tar.gz: 669249e17e1eae7db92176d0860d3d09d68f47bc90c68f5b3325c4cd9276f32aad47d14571fb61d117a33e2cac07adde6034fb68a21b59e8af07dbadfceaa468
data/CHANGELOG.md CHANGED
@@ -1,3 +1,28 @@
1
+ 1.17.3 / 2025-12-29
2
+ -------------------
3
+
4
+ Fixed:
5
+ * Opt-in for MFA requirement explicitly. #1159
6
+ * Fix type signature for FFI::AutoPointer#initialize, FFI::StructByReference#native_type and FFI::Struct#auto_ptr . #1158
7
+ * Fix function signature of function_call in FFI trampoline. #1154
8
+ It failed on `aarch64-mingw-ucrt`.
9
+ * Add workaround for segmentation faults on `aarch64-mingw-ucrt`. #1154
10
+ * Call super in `Library#freeze` . #1154
11
+ * Deny duplication of AutoPointer per #dup and #clone . #1173
12
+ They led to double free before.
13
+
14
+ Added:
15
+ * Add binary gems for Ruby-4.0, now providing binary gems for Ruby-3.0 to 4.0.
16
+ * Add msys2_mingw_dependencies for Windows Mingw for automatic installation of libffi. #1143
17
+ * Mark callback dispatcher thread as fork safe for Puma. #1156
18
+ * Add missing FFI::Platform module and LastError signatures. #1169
19
+
20
+ Removed:
21
+ * Drop fat binary gems for Ruby-2.7
22
+ * Remove `FFI::TypesGenerator` from distributed gems. #1164
23
+ * Remove libffi build dir after install, safing some install space. #1157
24
+
25
+
1
26
  1.17.2 / 2025-04-15
2
27
  -------------------
3
28
 
data/Gemfile CHANGED
@@ -1,13 +1,15 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gemspec
4
+
3
5
  group :development do
4
6
  gem 'benchmark' # necessary on ruby-3.5+
5
7
  gem 'bigdecimal' # necessary on ruby-3.3+
6
- gem 'bundler', '>= 1.16', '< 3'
7
- gem 'fiddle', platforms: %i[mri windows] # necessary on ruby-3.5+
8
+ gem 'bundler', '>= 1.16', '< 5.dev'
9
+ gem 'fiddle' # necessary on ruby-4.0+
8
10
  gem 'rake', '~> 13.0'
9
11
  gem 'rake-compiler', '~> 1.1'
10
- gem 'rake-compiler-dock', '~> 1.9.0'
12
+ gem 'rake-compiler-dock', '~> 1.11.0'
11
13
  gem 'rspec', '~> 3.0'
12
14
  end
13
15
 
@@ -17,7 +19,8 @@ group :doc do
17
19
  end
18
20
 
19
21
  group :type_check do
20
- if RUBY_VERSION >= "2.6" && %w[ ruby truffleruby ].include?(RUBY_ENGINE)
22
+ if RUBY_VERSION >= "3.0" && %w[ ruby truffleruby ].include?(RUBY_ENGINE)
21
23
  gem 'rbs', '~> 3.0'
24
+ gem 'steep', '~> 1.6'
22
25
  end
23
26
  end
data/README.md CHANGED
@@ -33,6 +33,7 @@ MyLib.puts 'Hello, World using libc!'
33
33
 
34
34
  For less minimalistic and more examples you may look at:
35
35
 
36
+ * The [documentation](https://www.rubydoc.info/gems/ffi)
36
37
  * the `samples/` folder
37
38
  * the examples on the [wiki](https://github.com/ffi/ffi/wiki)
38
39
  * the projects using FFI listed on the wiki: https://github.com/ffi/ffi/wiki/projects-using-ffi
data/Rakefile CHANGED
@@ -97,6 +97,7 @@ Bundler::GemHelper.instance.cross_platforms = %w[
97
97
  arm-linux-musl
98
98
  aarch64-linux-gnu
99
99
  aarch64-linux-musl
100
+ aarch64-mingw-ucrt
100
101
  x86_64-darwin
101
102
  arm64-darwin
102
103
  ]
@@ -111,6 +112,8 @@ if RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
111
112
  ext.cross_platform = Bundler::GemHelper.instance.cross_platforms
112
113
  ext.cross_compiling do |spec|
113
114
  spec.files.reject! { |path| File.fnmatch?('ext/*', path) }
115
+ # Binary gems don't need libffi header+lib files
116
+ spec.metadata.delete("msys2_mingw_dependencies")
114
117
  end
115
118
  # Enable debug info for 'rake compile' but not for 'gem install'
116
119
  ext.config_options << "--enable-debug"
@@ -126,7 +129,7 @@ end
126
129
  namespace "gem" do
127
130
  task 'prepare' do
128
131
  require 'rake_compiler_dock'
129
- sh "bundle package --all"
132
+ sh "bundle package"
130
133
  end
131
134
 
132
135
  Bundler::GemHelper.instance.cross_platforms.each do |plat|
@@ -137,8 +140,8 @@ namespace "gem" do
137
140
  task plat => ['prepare', 'build'] do
138
141
  RakeCompilerDock.sh <<-EOT, platform: plat
139
142
  sudo apt-get update && sudo apt-get install -y libltdl-dev &&
140
- bundle --local &&
141
- rake native:#{plat} pkg/#{gem_spec.full_name}-#{plat}.gem MAKE='nice make -j`nproc`' RUBY_CC_VERSION=#{RakeCompilerDock.ruby_cc_version("~>2.5", "~>3.0")}
143
+ bundle install --local &&
144
+ rake native:#{plat} pkg/#{gem_spec.full_name}-#{plat}.gem MAKE='nice make -j`nproc`' RUBY_CC_VERSION=#{RakeCompilerDock.ruby_cc_version("~>4.0", "~>3.0")}
142
145
  EOT
143
146
  end
144
147
  end
@@ -180,7 +183,7 @@ logfile = File.join(File.dirname(__FILE__), 'types_log')
180
183
 
181
184
  task types_conf do |task|
182
185
  require 'fileutils'
183
- require_relative "lib/ffi/tools/types_generator"
186
+ require_relative "rakelib/types_generator"
184
187
  options = {}
185
188
  FileUtils.mkdir_p(File.dirname(task.name), mode: 0755 )
186
189
  File.open(task.name, File::CREAT|File::TRUNC|File::RDWR, 0644) do |f|
data/Steepfile ADDED
@@ -0,0 +1,8 @@
1
+ target :lib do
2
+ signature "sig"
3
+
4
+ check "lib"
5
+
6
+ # ignore whole of lib, to just validate RBS in sig
7
+ ignore "lib"
8
+ end
data/ffi.gemspec CHANGED
@@ -15,9 +15,10 @@ Gem::Specification.new do |s|
15
15
  s.metadata['wiki_uri'] = 'https://github.com/ffi/ffi/wiki'
16
16
  s.metadata['source_code_uri'] = 'https://github.com/ffi/ffi/'
17
17
  s.metadata['mailing_list_uri'] = 'http://groups.google.com/group/ruby-ffi'
18
+ s.metadata['rubygems_mfa_required'] = 'true'
18
19
  end
19
20
  s.files = `git ls-files -z`.split("\x0").reject do |f|
20
- f =~ /^(\.|bench|gen|libtest|nbproject|spec)/
21
+ f =~ /^(\.|bench|gen|libtest|nbproject|spec|rakelib)/
21
22
  end
22
23
 
23
24
  # Add libffi git files
@@ -35,8 +36,6 @@ Gem::Specification.new do |s|
35
36
  s.license = 'BSD-3-Clause'
36
37
  s.require_paths << 'ext/ffi_c'
37
38
  s.required_ruby_version = '>= 2.5'
38
- s.add_development_dependency 'rake', '~> 13.0'
39
- s.add_development_dependency 'rake-compiler', '~> 1.1'
40
- s.add_development_dependency 'rake-compiler-dock', '~> 1.0'
41
- s.add_development_dependency 'rspec', '~> 2.14.1'
39
+
40
+ s.metadata['msys2_mingw_dependencies'] = 'libffi'
42
41
  end
data/lib/3.0/ffi_c.bundle CHANGED
Binary file
data/lib/3.1/ffi_c.bundle CHANGED
Binary file
data/lib/3.2/ffi_c.bundle CHANGED
Binary file
data/lib/3.3/ffi_c.bundle CHANGED
Binary file
data/lib/3.4/ffi_c.bundle CHANGED
Binary file
Binary file
@@ -89,6 +89,12 @@ module FFI
89
89
  self
90
90
  end
91
91
 
92
+ def dup
93
+ raise RuntimeError, "cannot duplicate FFI::AutoPointer"
94
+ end
95
+
96
+ alias clone dup
97
+
92
98
  # @return [nil]
93
99
  # Free the pointer.
94
100
  def free
data/lib/ffi/compat.rb CHANGED
@@ -40,4 +40,15 @@ module FFI
40
40
  obj.freeze
41
41
  end
42
42
  end
43
+
44
+ if defined?(Ractor.shareable_proc)
45
+ # This is for FFI internal use only.
46
+ def self.shareable_proc(**kwargs, &block)
47
+ Ractor.shareable_proc(**kwargs, &block)
48
+ end
49
+ else
50
+ def self.shareable_proc(**_kwargs, &block)
51
+ block
52
+ end
53
+ end
43
54
  end
data/lib/ffi/function.rb CHANGED
@@ -51,6 +51,29 @@ module FFI
51
51
  end
52
52
  end
53
53
 
54
+ if RUBY_PLATFORM == 'aarch64-mingw-ucrt'
55
+ # Use a workaround for https://github.com/libffi/libffi/issues/905
56
+ def attach(mod, name)
57
+ this = self
58
+ body = proc do |*args, &block|
59
+ this.call(*args, &block)
60
+ end
61
+
62
+ mod.define_method(name, body)
63
+ mod.define_singleton_method(name, body)
64
+
65
+ # Store function Proc's for re-definition as Ractor-shareable in Library#freeze
66
+ funcs = mod.instance_variable_get("@ffi_function_procs")
67
+ unless funcs
68
+ funcs = {}
69
+ mod.instance_variable_set("@ffi_function_procs", funcs)
70
+ end
71
+ funcs[name] = self
72
+
73
+ self
74
+ end
75
+ end
76
+
54
77
  # Stash the Function in a module variable so it can be inspected by attached_functions.
55
78
  # On CRuby it also ensures that it does not get garbage collected.
56
79
  module RegisterAttach
data/lib/ffi/library.rb CHANGED
@@ -287,7 +287,7 @@ module FFI
287
287
  if type.is_a?(Class) && type < FFI::Struct
288
288
  # If it is a global struct, just attach directly to the pointer
289
289
  s = s = type.new(address) # Assigning twice to suppress unused variable warning
290
- self.module_eval <<-code, __FILE__, __LINE__
290
+ self.module_eval(<<-code, __FILE__, __LINE__)
291
291
  @ffi_gsvars = {} unless defined?(@ffi_gsvars)
292
292
  @ffi_gsvars[#{mname.inspect}] = s
293
293
  def self.#{mname}
@@ -302,7 +302,7 @@ module FFI
302
302
  #
303
303
  # Attach to this module as mname/mname=
304
304
  #
305
- self.module_eval <<-code, __FILE__, __LINE__
305
+ self.module_eval(<<-code, __FILE__, __LINE__)
306
306
  @ffi_gvars = {} unless defined?(@ffi_gvars)
307
307
  @ffi_gvars[#{mname.inspect}] = s
308
308
  def self.#{mname}
@@ -564,12 +564,28 @@ module FFI
564
564
  # Freeze all definitions of the module
565
565
  #
566
566
  # This freezes the module's definitions, so that it can be used in a Ractor.
567
- # No further methods or variables can be attached and no further enums or typedefs can be created in this module afterwards.
567
+ # No further functions or variables can be attached and no further enums or typedefs can be created in this module afterwards.
568
568
  def freeze
569
+ # @ffi_function_procs is only used on aarch64-mingw-ucrt
570
+ instance_variable_get("@ffi_function_procs")&.each do |name, func|
571
+ # Redefine attached functions as Ractor-shareable.
572
+ # The function Proc can't be shareable from the beginning, since it references enums and typedefs.
573
+ this = FFI.make_shareable(func)
574
+ body = FFI.shareable_proc(self: nil) do |*args, &block|
575
+ this.call(*args, &block)
576
+ end
577
+ undef_method(name)
578
+ singleton_class.undef_method(name)
579
+
580
+ define_method(name, body)
581
+ define_singleton_method(name, body)
582
+ end
583
+
569
584
  instance_variables.each do |name|
570
585
  var = instance_variable_get(name)
571
586
  FFI.make_shareable(var)
572
587
  end
588
+ super
573
589
  nil
574
590
  end
575
591
  end
@@ -44,7 +44,7 @@ module FFI
44
44
  end
45
45
 
46
46
  # Always get {FFI::Type}::POINTER.
47
- def native_type
47
+ def native_type(_type = nil)
48
48
  FFI::Type::POINTER
49
49
  end
50
50
 
data/lib/ffi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module FFI
2
- VERSION = '1.17.2'
2
+ VERSION = '1.17.3'
3
3
  end
@@ -1,5 +1,13 @@
1
+ # See the ffi wiki for how to use FFI with Ractors:
2
+ # https://github.com/ffi/ffi/wiki/Ractors
3
+
1
4
  require 'ffi'
2
5
 
6
+ class Ractor
7
+ # compat with Ruby-3.4 and older
8
+ alias value take unless method_defined? :value
9
+ end
10
+
3
11
  module Foo
4
12
  extend FFI::Library
5
13
  ffi_lib FFI::Library::LIBC
@@ -8,4 +16,4 @@ module Foo
8
16
  end
9
17
  Ractor.new do
10
18
  Foo.cputs("Hello, World via libc puts using FFI in a Ractor")
11
- end.take
19
+ end.value
@@ -1,5 +1,13 @@
1
+ # See the ffi wiki for how to use FFI with Ractors:
2
+ # https://github.com/ffi/ffi/wiki/Ractors
3
+
1
4
  require 'ffi'
2
5
 
6
+ class Ractor
7
+ # compat with Ruby-3.4 and older
8
+ alias value take unless method_defined? :value
9
+ end
10
+
3
11
  module LibC
4
12
  extend FFI::Library
5
13
  ffi_lib FFI::Library::LIBC
@@ -23,6 +31,6 @@ res = Ractor.new(p) do |p|
23
31
  i1 < i2 ? -1 : i1 > i2 ? 1 : 0
24
32
  end
25
33
  puts "After qsort #{p.get_array_of_int32(0, 3).join(', ')}"
26
- end.take
34
+ end.value
27
35
 
28
36
  puts "After ractor termination #{p.get_array_of_int32(0, 3).join(', ')}"
@@ -12,7 +12,7 @@ module FFI
12
12
  def release: (Pointer ptr) -> void
13
13
  end
14
14
 
15
- def initialize: (Pointer pointer, Method | ^(self) -> void | Releaser::_Proc[self] callable) -> self
15
+ def initialize: (Pointer pointer, Method | ^(instance) -> void | Releaser::_Proc[instance] callable) -> self
16
16
  | (Pointer pointer) -> self # where class < `def self.release: (instance pointer) -> void`
17
17
 
18
18
  extend DataConverter[Pointer, instance, nil]
data/sig/ffi/errno.rbs ADDED
@@ -0,0 +1,8 @@
1
+ module FFI
2
+ module LastError
3
+ def self?.error: () -> Integer
4
+ def self?.error=: (Integer) -> Integer
5
+ def self?.winapi_error: () -> Integer?
6
+ def self?.winapi_error=: (Integer? error) -> void
7
+ end
8
+ end
@@ -0,0 +1,49 @@
1
+ module FFI
2
+ class PlatformError < LoadError
3
+ end
4
+
5
+ module Platform
6
+ OS: String
7
+
8
+ OSVERSION: Integer
9
+
10
+ CPU: String
11
+
12
+ ARCH: String
13
+
14
+ IS_GNU: bool
15
+ IS_LINUX: bool
16
+ IS_MAC: bool
17
+ IS_FREEBSD: bool
18
+ IS_NETBSD: bool
19
+ IS_OPENBSD: bool
20
+ IS_DRAGONFLYBSD: bool
21
+ IS_SOLARIS: bool
22
+ IS_WINDOWS: bool
23
+ IS_BSD: bool
24
+
25
+ NAME: String
26
+
27
+ CONF_DIR: String
28
+
29
+ LIBPREFIX: String
30
+
31
+ LIBSUFFIX: String
32
+
33
+ LIBC: String
34
+
35
+ LITTLE_ENDIAN: Integer
36
+
37
+ BIG_ENDIAN: Integer
38
+
39
+ def self.bsd?: () -> bool
40
+ def self.windows?: () -> bool
41
+ def self.mac?: () -> bool
42
+ def self.solaris?: () -> bool
43
+ def self.unix?: () -> bool
44
+
45
+ private
46
+
47
+ def self.is_os: (String os) -> bool
48
+ end
49
+ end
data/sig/ffi/struct.rbs CHANGED
@@ -4,7 +4,7 @@ module FFI
4
4
 
5
5
  type ptr = Type::Mapped[
6
6
  StructByReference[Struct[AbstractMemory, untyped], AbstractMemory],
7
- AbstractMemory, instance, untyped
7
+ AbstractMemory, Struct[AbstractMemory, untyped], untyped
8
8
  ]
9
9
  def self.ptr: (?untyped flags) -> ptr # https://github.com/ffi/ffi/issues/1073
10
10
  alias self.by_ref self.ptr
@@ -22,7 +22,7 @@ module FFI
22
22
 
23
23
  def self.auto_ptr: () -> Type::Mapped[
24
24
  ManagedStructConverter[ManagedStruct[AutoPointer, untyped], AutoPointer],
25
- Pointer, instance, untyped
25
+ Pointer, ManagedStruct[AutoPointer, untyped], untyped
26
26
  ]
27
27
  def self.layout: (*layout | Integer) -> StructLayout
28
28
  | (Hash[Symbol, layout]) -> StructLayout
@@ -5,7 +5,7 @@ module FFI
5
5
 
6
6
  def initialize: (S struct_class) -> void
7
7
  def from_native: (P value, untyped ctx) -> S
8
- def native_type: () -> Type::Builtin
8
+ def native_type: (?ffi_auto_type? type) -> Type
9
9
  def to_native: (S? value, untyped ctx) -> P
10
10
  end
11
11
  end
data/sig/ffi.rbs CHANGED
@@ -14,9 +14,12 @@ module FFI
14
14
  CURRENT_PROCESS: current_process
15
15
  USE_THIS_PROCESS_AS_LIBRARY: current_process
16
16
 
17
+ class NotFoundError < LoadError
18
+ end
19
+
17
20
  private def self.custom_typedefs: () -> type_map
18
21
  def self.errno: () -> Integer
19
- def self.errno=: (Integer) -> nil
22
+ def self.errno=: (Integer) -> Integer
20
23
  def self.find_type: (ffi_auto_type name, ?type_map? type_map) -> Type
21
24
  def self.make_shareable: [T] (T obj) -> T
22
25
  def self.map_library_name: (_ToS lib) -> String
metadata CHANGED
@@ -1,70 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.17.2
4
+ version: 1.17.3
5
5
  platform: arm64-darwin
6
6
  authors:
7
7
  - Wayne Meissner
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-04-15 00:00:00.000000000 Z
11
- dependencies:
12
- - !ruby/object:Gem::Dependency
13
- name: rake
14
- requirement: !ruby/object:Gem::Requirement
15
- requirements:
16
- - - "~>"
17
- - !ruby/object:Gem::Version
18
- version: '13.0'
19
- type: :development
20
- prerelease: false
21
- version_requirements: !ruby/object:Gem::Requirement
22
- requirements:
23
- - - "~>"
24
- - !ruby/object:Gem::Version
25
- version: '13.0'
26
- - !ruby/object:Gem::Dependency
27
- name: rake-compiler
28
- requirement: !ruby/object:Gem::Requirement
29
- requirements:
30
- - - "~>"
31
- - !ruby/object:Gem::Version
32
- version: '1.1'
33
- type: :development
34
- prerelease: false
35
- version_requirements: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '1.1'
40
- - !ruby/object:Gem::Dependency
41
- name: rake-compiler-dock
42
- requirement: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '1.0'
47
- type: :development
48
- prerelease: false
49
- version_requirements: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '1.0'
54
- - !ruby/object:Gem::Dependency
55
- name: rspec
56
- requirement: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: 2.14.1
61
- type: :development
62
- prerelease: false
63
- version_requirements: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: 2.14.1
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
68
12
  description: Ruby FFI library
69
13
  email: wmeissner@gmail.com
70
14
  executables: []
@@ -78,15 +22,14 @@ files:
78
22
  - LICENSE.SPECS
79
23
  - README.md
80
24
  - Rakefile
25
+ - Steepfile
81
26
  - ffi.gemspec
82
- - lib/2.5/ffi_c.bundle
83
- - lib/2.6/ffi_c.bundle
84
- - lib/2.7/ffi_c.bundle
85
27
  - lib/3.0/ffi_c.bundle
86
28
  - lib/3.1/ffi_c.bundle
87
29
  - lib/3.2/ffi_c.bundle
88
30
  - lib/3.3/ffi_c.bundle
89
31
  - lib/3.4/ffi_c.bundle
32
+ - lib/4.0/ffi_c.bundle
90
33
  - lib/ffi.rb
91
34
  - lib/ffi/abstract_memory.rb
92
35
  - lib/ffi/autopointer.rb
@@ -172,12 +115,10 @@ files:
172
115
  - lib/ffi/tools/generator.rb
173
116
  - lib/ffi/tools/generator_task.rb
174
117
  - lib/ffi/tools/struct_generator.rb
175
- - lib/ffi/tools/types_generator.rb
176
118
  - lib/ffi/types.rb
177
119
  - lib/ffi/union.rb
178
120
  - lib/ffi/variadic.rb
179
121
  - lib/ffi/version.rb
180
- - rakelib/ffi_gem_helper.rb
181
122
  - samples/getlogin.rb
182
123
  - samples/getpid.rb
183
124
  - samples/gettimeofday.rb
@@ -194,9 +135,11 @@ files:
194
135
  - sig/ffi/data_converter.rbs
195
136
  - sig/ffi/dynamic_library.rbs
196
137
  - sig/ffi/enum.rbs
138
+ - sig/ffi/errno.rbs
197
139
  - sig/ffi/function.rbs
198
140
  - sig/ffi/library.rbs
199
141
  - sig/ffi/native_type.rbs
142
+ - sig/ffi/platform.rbs
200
143
  - sig/ffi/pointer.rbs
201
144
  - sig/ffi/struct.rbs
202
145
  - sig/ffi/struct_by_reference.rbs
@@ -214,6 +157,7 @@ metadata:
214
157
  wiki_uri: https://github.com/ffi/ffi/wiki
215
158
  source_code_uri: https://github.com/ffi/ffi/
216
159
  mailing_list_uri: http://groups.google.com/group/ruby-ffi
160
+ rubygems_mfa_required: 'true'
217
161
  rdoc_options:
218
162
  - "--exclude=ext/ffi_c/.*\\.o$"
219
163
  - "--exclude=ffi_c\\.(bundle|so)$"
@@ -223,17 +167,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
223
167
  requirements:
224
168
  - - ">="
225
169
  - !ruby/object:Gem::Version
226
- version: '2.5'
170
+ version: '3.0'
227
171
  - - "<"
228
172
  - !ruby/object:Gem::Version
229
- version: 3.5.dev
173
+ version: 4.1.dev
230
174
  required_rubygems_version: !ruby/object:Gem::Requirement
231
175
  requirements:
232
176
  - - ">="
233
177
  - !ruby/object:Gem::Version
234
178
  version: '0'
235
179
  requirements: []
236
- rubygems_version: 3.6.2
180
+ rubygems_version: 4.0.3
237
181
  specification_version: 4
238
182
  summary: Ruby FFI
239
183
  test_files: []
data/lib/2.5/ffi_c.bundle DELETED
Binary file
data/lib/2.6/ffi_c.bundle DELETED
Binary file
data/lib/2.7/ffi_c.bundle DELETED
Binary file
@@ -1,137 +0,0 @@
1
- require 'tempfile'
2
-
3
- module FFI
4
-
5
- # @private
6
- class TypesGenerator
7
-
8
- ##
9
- # Maps different C types to the C type representations we use
10
-
11
- TYPE_MAP = {
12
- "char" => :char,
13
- "signed char" => :char,
14
- "__signed char" => :char,
15
- "unsigned char" => :uchar,
16
-
17
- "short" => :short,
18
- "signed short" => :short,
19
- "signed short int" => :short,
20
- "unsigned short" => :ushort,
21
- "unsigned short int" => :ushort,
22
-
23
- "int" => :int,
24
- "signed int" => :int,
25
- "unsigned int" => :uint,
26
-
27
- "long" => :long,
28
- "long int" => :long,
29
- "signed long" => :long,
30
- "signed long int" => :long,
31
- "unsigned long" => :ulong,
32
- "unsigned long int" => :ulong,
33
- "long unsigned int" => :ulong,
34
-
35
- "long long" => :long_long,
36
- "long long int" => :long_long,
37
- "signed long long" => :long_long,
38
- "signed long long int" => :long_long,
39
- "unsigned long long" => :ulong_long,
40
- "unsigned long long int" => :ulong_long,
41
-
42
- "char *" => :string,
43
- "void *" => :pointer,
44
- }
45
-
46
- def self.generate(options = {})
47
- typedefs = nil
48
- Tempfile.open 'ffi_types_generator' do |io|
49
- io.puts <<-C
50
- #include <stdint.h>
51
- #include <stddef.h>
52
- #include <sys/types.h>
53
- #if !(defined(WIN32))
54
- #include <sys/socket.h>
55
- #include <netinet/in.h>
56
- #include <sys/resource.h>
57
- #endif
58
- C
59
-
60
- io.close
61
- cc = ENV['CC'] || 'gcc'
62
- cmd = "#{cc} -E -x c #{options[:cppflags]} -D_DARWIN_USE_64_BIT_INODE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -c"
63
- if options[:input]
64
- typedefs = File.read(options[:input])
65
- elsif options[:remote]
66
- typedefs = `ssh #{options[:remote]} #{cmd} - < #{io.path}`
67
- else
68
- typedefs = `#{cmd} #{io.path}`
69
- end
70
- end
71
-
72
- code = []
73
-
74
- typedefs.each_line do |type|
75
- # We only care about single line typedef
76
- next unless type =~ /typedef/
77
- # Ignore unions or structs
78
- next if type =~ /union|struct/
79
-
80
- # strip off the starting typedef and ending ;
81
- type.gsub!(/^(.*typedef\s*)/, "")
82
- type.gsub!(/\s*;\s*$/, "")
83
-
84
- parts = type.split(/\s+/)
85
- def_type = parts.join(" ")
86
-
87
- # GCC does mapping with __attribute__ stuf, also see
88
- # http://hal.cs.berkeley.edu/cil/cil016.html section 16.2.7. Problem
89
- # with this is that the __attribute__ stuff can either occur before or
90
- # after the new type that is defined...
91
- if type =~ /__attribute__/
92
- if parts.last =~ /__QI__|__HI__|__SI__|__DI__|__word__/
93
-
94
- # In this case, the new type is BEFORE __attribute__ we need to
95
- # find the final_type as the type before the part that starts with
96
- # __attribute__
97
- final_type = ""
98
- parts.each do |p|
99
- break if p =~ /__attribute__/
100
- final_type = p
101
- end
102
- else
103
- final_type = parts.pop
104
- end
105
-
106
- def_type = case type
107
- when /__QI__/ then "char"
108
- when /__HI__/ then "short"
109
- when /__SI__/ then "int"
110
- when /__DI__/ then "long long"
111
- when /__word__/ then "long"
112
- else "int"
113
- end
114
-
115
- def_type = "unsigned #{def_type}" if type =~ /unsigned/
116
- else
117
- final_type = parts.pop
118
- def_type = parts.join(" ")
119
- end
120
-
121
- if type = TYPE_MAP[def_type]
122
- code << "rbx.platform.typedef.#{final_type} = #{type}"
123
- TYPE_MAP[final_type] = TYPE_MAP[def_type]
124
- else
125
- # Fallback to an ordinary pointer if we don't know the type
126
- if def_type =~ /\*/
127
- code << "rbx.platform.typedef.#{final_type} = pointer"
128
- TYPE_MAP[final_type] = :pointer
129
- end
130
- end
131
- end
132
-
133
- code.sort.join("\n")
134
- end
135
- end
136
- end
137
-
@@ -1,65 +0,0 @@
1
- require 'bundler'
2
- require 'bundler/gem_helper'
3
-
4
- class FfiGemHelper < Bundler::GemHelper
5
- attr_accessor :cross_platforms
6
-
7
- def install
8
- super
9
-
10
- task "release:guard_clean" => ["release:update_history"]
11
-
12
- task "release:update_history" do
13
- update_history
14
- end
15
-
16
- task "release:rubygem_push" => ["gem:native", "gem:java"]
17
- end
18
-
19
- def hfile
20
- "CHANGELOG.md"
21
- end
22
-
23
- def headline
24
- '([^\w]*)(\d+\.\d+\.\d+(?:\.\w+)?)([^\w]+)([2Y][0Y][0-9Y][0-9Y]-[0-1M][0-9M]-[0-3D][0-9D])([^\w]*|$)'
25
- end
26
-
27
- def reldate
28
- Time.now.strftime("%Y-%m-%d")
29
- end
30
-
31
- def update_history
32
- hin = File.read(hfile)
33
- hout = hin.sub(/#{headline}/) do
34
- raise "#{hfile} isn't up-to-date for version #{version}" unless $2==version.to_s
35
- $1 + $2 + $3 + reldate + $5
36
- end
37
- if hout != hin
38
- Bundler.ui.confirm "Updating #{hfile} for release."
39
- File.write(hfile, hout)
40
- Rake::FileUtilsExt.sh "git", "commit", hfile, "-m", "Update release date in #{hfile}"
41
- end
42
- end
43
-
44
- def tag_version
45
- Bundler.ui.confirm "Tag release with annotation:"
46
- m = File.read(hfile).match(/(?<annotation>#{headline}.*?)#{headline}/m) || raise("Unable to find release notes in #{hfile}")
47
- Bundler.ui.info(m[:annotation].gsub(/^/, " "))
48
- IO.popen(["git", "tag", "--file=-", version_tag], "w") do |fd|
49
- fd.write m[:annotation]
50
- end
51
- yield if block_given?
52
- rescue
53
- Bundler.ui.error "Untagging #{version_tag} due to error."
54
- sh_with_code "git tag -d #{version_tag}"
55
- raise
56
- end
57
-
58
- def rubygem_push(path)
59
- cross_platforms.each do |ruby_platform|
60
- super(path.gsub(/\.gem\z/, "-#{ruby_platform}.gem"))
61
- end
62
- super(path.gsub(/\.gem\z/, "-java.gem"))
63
- super(path)
64
- end
65
- end