ffi 1.16.3-java → 1.17.0-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 403b38da3c452f3c1e3ec39766ca596f2d53e5b1424af3e8bc2f862ca2f72207
4
- data.tar.gz: 96c88fe35bd5da21b3d96d708db99e481f935d91003998501d5e3638acad65ba
3
+ metadata.gz: 339482a2db268d08ac79e7205fb1dd77b83f06c6a69f698cd35eed5e4063e899
4
+ data.tar.gz: 022aa0d53823dc33bf77698efac9f057c9ad5987819fd1c2ad3b2f90ad3f7be6
5
5
  SHA512:
6
- metadata.gz: 62ac330100dfe633091c289dbf90c0219bb31111c7ef123b831ffd5411672d6d4e9ed7345a465003cf1a4ce87b6349e55bf1b81e967452c077dc7763e0b6c2b0
7
- data.tar.gz: 06bef35a44ca4eedfc5042f5d962ac1b23d974f82b7f262701d7fc3213fa5cd5a93dfd4e80846ec4a71417509d7a7614bd73f8f9abe6a77f6aa68db0fecf34f8
6
+ metadata.gz: 68f15f9afd458da3fb4aa52debe5418a6732184f27d40ca3c85ada225f0192b7b6a7db3b631896d57933c8d9ac2d272254798a9c72db1c958076d444a36cb726
7
+ data.tar.gz: 7a9181876be8f2c46317f0c00f801fe1748d8e4716df99adf9d8d864146c6d49d6b40ae6b64bb2a33709956df6128d4254eaadaeff61547416f11e6a83b4c34c
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,3 +1,45 @@
1
+ 1.17.0 / 2024-06-02
2
+ -------------------
3
+
4
+ Fixed:
5
+ * Add FFI::AbstractMemory#read_array_of_string . It was defined but not exposed to Ruby nor tested. #1070
6
+
7
+
8
+ 1.17.0.rc2 / 2024-04-22
9
+ -------------------
10
+
11
+ Fixed:
12
+ * Add missing write barriers to StructLayout#initialize causing a segfault with GC.stress. #1079
13
+
14
+
15
+ 1.17.0.rc1 / 2024-04-08
16
+ -------------------
17
+
18
+ Fixed:
19
+ * Fix type definitions on `aarch64-linux`. #1067, #1066
20
+ * Use RB_TEST for `Pointer.autorelease=` . #1065
21
+ So that `false` and `nil` are treated as falsey and anything else as truthy.
22
+ * Replace Fixnum by Integer. #1064
23
+ Fixnum is no longer present in the ruby language.
24
+ * Update `FFI::NativeType` doc. #1061
25
+ * Store FFI::Type::Mapped of FFI::StrPtrConverter in global instead of custom type map
26
+ * Various documentation fixes. #1042
27
+ * Update `FFI::Pointer#==` to return `false` if a pointer is compared to a non-pointer object, which is the expected behavior. #1083
28
+ * Avoid warning about undefined wariable `@ffi_functions` #1085
29
+ * Fix a very unlikely GC bug when using a callback block. # 1089
30
+
31
+ Added:
32
+ * Provide binary gems for many platforms. #990
33
+ * Add Windows fat binary gem for Ruby-3.3
34
+ * Add RBS type definitions for many user facing parts of the FFI API. #1042
35
+ * Improve fallback search path logic. #1088
36
+ Respect LD_LIBRARY_PATH and DYLD_LIBRARY_PATH on Macos.
37
+ * Update libffi to current git master branch.
38
+
39
+ Removed:
40
+ * Remove `enum CHAR_ARRAY` which is no longer used. #1063
41
+
42
+
1
43
  1.16.3 / 2023-10-04
2
44
  -------------------
3
45
 
data/Gemfile CHANGED
@@ -1,14 +1,21 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  group :development do
4
+ gem 'bigdecimal' # necessary on ruby-3.3+
5
+ gem 'bundler', '>= 1.16', '< 3'
4
6
  gem 'rake', '~> 13.0'
5
7
  gem 'rake-compiler', '~> 1.1'
6
- gem 'rake-compiler-dock', '~> 1.0'
8
+ gem 'rake-compiler-dock', '~> 1.0.pre'
7
9
  gem 'rspec', '~> 3.0'
8
- gem 'bundler', '>= 1.16', '< 3'
9
10
  end
10
11
 
11
12
  group :doc do
12
13
  gem 'kramdown'
13
14
  gem 'yard', '~> 0.9'
14
15
  end
16
+
17
+ group :type_check do
18
+ if RUBY_VERSION >= "2.6" && %w[ ruby truffleruby ].include?(RUBY_ENGINE)
19
+ gem 'rbs', '~> 3.0'
20
+ end
21
+ end
data/README.md CHANGED
@@ -114,7 +114,7 @@ The following people have submitted code, bug reports, or otherwise contributed
114
114
  * Jurij Smakov <jurij@wooyd.org>
115
115
  * KISHIMOTO, Makoto <ksmakoto@dd.iij4u.or.jp>
116
116
  * Kim Burgestrand <kim@burgestrand.se>
117
- * Lars Kanis <kanis@comcard.de>
117
+ * Lars Kanis <lars@greiz-reinsdorf.de>
118
118
  * Luc Heinrich <luc@honk-honk.com>
119
119
  * Luis Lavena <luislavena@gmail.com>
120
120
  * Matijs van Zuijlen <matijs@matijs.net>
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ BUILD_EXT_DIR = File.join(BUILD_DIR, "#{RbConfig::CONFIG['arch']}", 'ffi_c', RUB
13
13
 
14
14
  gem_spec = Bundler.load_gemspec('ffi.gemspec')
15
15
 
16
- RSpec::Core::RakeTask.new(:spec => :compile) do |config|
16
+ RSpec::Core::RakeTask.new(:spec) do |config|
17
17
  config.rspec_opts = YAML.load_file 'spec/spec.opts'
18
18
  end
19
19
 
@@ -84,10 +84,22 @@ end
84
84
  task 'gem:java' => 'java:gem'
85
85
 
86
86
  FfiGemHelper.install_tasks
87
- # Register windows gems to be pushed to rubygems.org
88
- Bundler::GemHelper.instance.cross_platforms = %w[x86-mingw32 x64-mingw-ucrt x64-mingw32]
89
- # These platforms are not yet enabled, since there are issues on musl-based distors (alpine-linux):
90
- # + %w[x86-linux x86_64-linux arm-linux aarch64-linux x86_64-darwin arm64-darwin]
87
+ # Register binary gems to be pushed to rubygems.org
88
+ Bundler::GemHelper.instance.cross_platforms = %w[
89
+ x86-mingw32
90
+ x64-mingw-ucrt
91
+ x64-mingw32
92
+ x86-linux-gnu
93
+ x86-linux-musl
94
+ x86_64-linux-gnu
95
+ x86_64-linux-musl
96
+ arm-linux-gnu
97
+ arm-linux-musl
98
+ aarch64-linux-gnu
99
+ aarch64-linux-musl
100
+ x86_64-darwin
101
+ arm64-darwin
102
+ ]
91
103
 
92
104
  if RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
93
105
  require 'rake/extensiontask'
@@ -45,14 +45,6 @@ module FFI
45
45
  # @note WARNING: passing a proc _may_ cause your pointer to never be
46
46
  # GC'd, unless you're careful to avoid trapping a reference to the
47
47
  # pointer in the proc. See the test specs for examples.
48
- # @overload initialize(pointer) { |p| ... }
49
- # @param pointer [Pointer]
50
- # @yieldparam [Pointer] p +pointer+ passed to the block
51
- # @return [self]
52
- # The passed block will be invoked at GC time.
53
- # @note
54
- # WARNING: passing a block will cause your pointer to never be GC'd.
55
- # This is bad.
56
48
  # @overload initialize(pointer)
57
49
  # @param pointer [Pointer]
58
50
  # @return [self]
@@ -75,7 +67,7 @@ module FFI
75
67
  # The last calling idiom (only one parameter) is generally only
76
68
  # going to be useful if you subclass {AutoPointer}, and override
77
69
  # #release, which by default does nothing.
78
- def initialize(ptr, proc=nil, &block)
70
+ def initialize(ptr, proc=nil)
79
71
  raise TypeError, "Invalid pointer" if ptr.nil? || !ptr.kind_of?(Pointer) ||
80
72
  ptr.kind_of?(MemoryPointer) || ptr.kind_of?(AutoPointer)
81
73
  super(ptr.type_size, ptr)
@@ -30,12 +30,41 @@
30
30
 
31
31
  module FFI
32
32
  class DynamicLibrary
33
- SEARCH_PATH = %w[/usr/lib /usr/local/lib /opt/local/lib]
34
- if FFI::Platform::ARCH == 'aarch64' && FFI::Platform.mac?
35
- SEARCH_PATH << '/opt/homebrew/lib'
33
+ SEARCH_PATH = []
34
+
35
+ # The following search paths are tried, if the library could not be loaded in the first attempt.
36
+ # They are only executed on Macos in the following order:
37
+ if FFI::Platform.mac?
38
+
39
+ # 1. Try library paths possibly defined in LD_LIBRARY_PATH DYLD_LIBRARY_PATH first.
40
+ # This is because dlopen doesn't respect LD_LIBRARY_PATH and DYLD_LIBRARY_PATH is deleted by SIP-protected binaries.
41
+ # See here for details: https://github.com/ffi/ffi/issues/923#issuecomment-1872565313
42
+ %w[LD_LIBRARY_PATH DYLD_LIBRARY_PATH].each do |custom_path|
43
+ SEARCH_PATH.concat ENV.fetch(custom_path,"").split(File::PATH_SEPARATOR)
44
+ end
45
+
46
+ # 2. Then on macos/arm64 try /opt/homebrew/lib, since this is a typical standard directory.
47
+ # FFI is often used together with homebrew, so that we hardcode the path for arm64 here.
48
+ if FFI::Platform::ARCH == 'aarch64'
49
+ SEARCH_PATH << '/opt/homebrew/lib'
50
+ end
51
+
52
+ # 3. Then try typical system directories starting with the /local/ directory first.
53
+ #
54
+ # /usr/local/lib is used by homebrow on x86_64.
55
+ # /opt/local/lib is used by MacPorts and Fink.
56
+ # /usr/lib is there, because it was always there.
57
+ SEARCH_PATH.concat %w[/opt/local/lib /usr/local/lib /usr/lib]
36
58
  end
37
59
 
38
- SEARCH_PATH_MESSAGE = "Searched in <system library path>, #{SEARCH_PATH.join(', ')}".freeze
60
+ # On Linux the library lookup paths are usually defined through /etc/ld.so.conf, which can be changed at will with root permissions.
61
+ # Also LD_LIBRARY_PATH is respected by the dynamic loader, so that there's usually no need and no advantage to do a fallback handling.
62
+ #
63
+ # Windows has it's own library lookup logic, very different to what we do here.
64
+ # See: https://github.com/oneclick/rubyinstaller2/wiki/For-gem-developers#user-content-dll-loading
65
+
66
+ FFI.make_shareable(SEARCH_PATH)
67
+ SEARCH_PATH_MESSAGE = "Searched in <system library path>#{ SEARCH_PATH.map{|a| ', ' + a}.join }".freeze
39
68
 
40
69
  def self.load_library(name, flags)
41
70
  if name == FFI::CURRENT_PROCESS
@@ -51,7 +80,7 @@ module FFI
51
80
  lib = try_load(libname, flags, errors)
52
81
  return lib if lib
53
82
 
54
- unless libname.start_with?("/") || FFI::Platform.windows?
83
+ unless libname.start_with?("/")
55
84
  SEARCH_PATH.each do |prefix|
56
85
  path = "#{prefix}/#{libname}"
57
86
  if File.exist?(path)
data/lib/ffi/enum.rb CHANGED
@@ -35,7 +35,6 @@ module FFI
35
35
  # An instance of this class permits to manage {Enum}s. In fact, Enums is a collection of {Enum}s.
36
36
  class Enums
37
37
 
38
- # @return [nil]
39
38
  def initialize
40
39
  @all_enums = Array.new
41
40
  @tagged_enums = Hash.new
data/lib/ffi/function.rb CHANGED
@@ -55,7 +55,7 @@ module FFI
55
55
  # On CRuby it also ensures that it does not get garbage collected.
56
56
  module RegisterAttach
57
57
  def attach(mod, name)
58
- funcs = mod.instance_variable_get("@ffi_functions")
58
+ funcs = mod.instance_variable_defined?("@ffi_functions") && mod.instance_variable_get("@ffi_functions")
59
59
  unless funcs
60
60
  funcs = {}
61
61
  mod.instance_variable_set("@ffi_functions", funcs)
data/lib/ffi/io.rb CHANGED
@@ -42,9 +42,9 @@ module FFI
42
42
 
43
43
  # @param [#read] io io to read from
44
44
  # @param [AbstractMemory] buf destination for data read from +io+
45
- # @param [nil, Numeric] len maximul number of bytes to read from +io+. If +nil+,
45
+ # @param [nil, Integer] len maximul number of bytes to read from +io+. If +nil+,
46
46
  # read until end of file.
47
- # @return [Numeric] length really read, in bytes
47
+ # @return [Integer] length really read, in bytes
48
48
  #
49
49
  # A version of IO#read that reads data from an IO and put then into a native buffer.
50
50
  #
data/lib/ffi/library.rb CHANGED
@@ -135,7 +135,7 @@ module FFI
135
135
  # ffi_lib_flags(:lazy, :local) # => 5
136
136
  #
137
137
  # @param [Symbol, …] flags (see {FlagsMap})
138
- # @return [Fixnum] the new value
138
+ # @return [Integer] the new value
139
139
  def ffi_lib_flags(*flags)
140
140
  @ffi_lib_flags = flags.inject(0) { |result, f| result | FlagsMap[f] }
141
141
  end
@@ -395,6 +395,26 @@ module FFI
395
395
  end
396
396
  end
397
397
 
398
+ # @param [DataConverter, Type, Struct, Symbol] t type to find
399
+ # @return [Type]
400
+ # Find a type definition.
401
+ def find_type(t)
402
+ if t.kind_of?(Type)
403
+ t
404
+
405
+ elsif defined?(@ffi_typedefs) && @ffi_typedefs.has_key?(t)
406
+ @ffi_typedefs[t]
407
+
408
+ elsif t.is_a?(Class) && t < Struct
409
+ Type::POINTER
410
+
411
+ elsif t.is_a?(DataConverter)
412
+ # Add a typedef so next time the converter is used, it hits the cache
413
+ typedef Type::Mapped.new(t), t
414
+
415
+ end || FFI.find_type(t)
416
+ end
417
+
398
418
  private
399
419
  # Generic enum builder
400
420
  # @param [Class] klass can be one of FFI::Enum or FFI::Bitmask
@@ -515,26 +535,6 @@ module FFI
515
535
  @ffi_enums.__map_symbol(symbol)
516
536
  end
517
537
 
518
- # @param [DataConverter, Type, Struct, Symbol] t type to find
519
- # @return [Type]
520
- # Find a type definition.
521
- def find_type(t)
522
- if t.kind_of?(Type)
523
- t
524
-
525
- elsif defined?(@ffi_typedefs) && @ffi_typedefs.has_key?(t)
526
- @ffi_typedefs[t]
527
-
528
- elsif t.is_a?(Class) && t < Struct
529
- Type::POINTER
530
-
531
- elsif t.is_a?(DataConverter)
532
- # Add a typedef so next time the converter is used, it hits the cache
533
- typedef Type::Mapped.new(t), t
534
-
535
- end || FFI.find_type(t)
536
- end
537
-
538
538
  # Retrieve all attached functions and their function signature
539
539
  #
540
540
  # This method returns a Hash of method names of attached functions connected by #attach_function and the corresponding function type.
@@ -552,10 +552,10 @@ module FFI
552
552
  # @return [Hash< Symbol => ffi_type >]
553
553
  def attached_variables
554
554
  (
555
- (@ffi_gsvars || {}).map do |name, gvar|
555
+ (defined?(@ffi_gsvars) ? @ffi_gsvars : {}).map do |name, gvar|
556
556
  [name, gvar.class]
557
557
  end +
558
- (@ffi_gvars || {}).map do |name, gvar|
558
+ (defined?(@ffi_gvars) ? @ffi_gvars : {}).map do |name, gvar|
559
559
  [name, gvar.layout[:gvar].type]
560
560
  end
561
561
  ).to_h
@@ -1,5 +1,4 @@
1
1
  rbx.platform.typedef.*__caddr_t = char
2
- rbx.platform.typedef.*__qaddr_t = long
3
2
  rbx.platform.typedef.__blkcnt64_t = long
4
3
  rbx.platform.typedef.__blkcnt_t = long
5
4
  rbx.platform.typedef.__blksize_t = int
@@ -21,7 +20,43 @@ rbx.platform.typedef.__int16_t = short
21
20
  rbx.platform.typedef.__int32_t = int
22
21
  rbx.platform.typedef.__int64_t = long
23
22
  rbx.platform.typedef.__int8_t = char
23
+ rbx.platform.typedef.__int_least16_t = short
24
+ rbx.platform.typedef.__int_least32_t = int
25
+ rbx.platform.typedef.__int_least64_t = long
26
+ rbx.platform.typedef.__int_least8_t = char
27
+ rbx.platform.typedef.__intmax_t = long
24
28
  rbx.platform.typedef.__intptr_t = long
29
+ rbx.platform.typedef.__kernel_caddr_t = string
30
+ rbx.platform.typedef.__kernel_clock_t = long
31
+ rbx.platform.typedef.__kernel_clockid_t = int
32
+ rbx.platform.typedef.__kernel_daddr_t = int
33
+ rbx.platform.typedef.__kernel_gid16_t = ushort
34
+ rbx.platform.typedef.__kernel_gid32_t = uint
35
+ rbx.platform.typedef.__kernel_gid_t = uint
36
+ rbx.platform.typedef.__kernel_ino_t = ulong
37
+ rbx.platform.typedef.__kernel_ipc_pid_t = int
38
+ rbx.platform.typedef.__kernel_key_t = int
39
+ rbx.platform.typedef.__kernel_loff_t = long_long
40
+ rbx.platform.typedef.__kernel_long_t = long
41
+ rbx.platform.typedef.__kernel_mode_t = uint
42
+ rbx.platform.typedef.__kernel_mqd_t = int
43
+ rbx.platform.typedef.__kernel_off_t = long
44
+ rbx.platform.typedef.__kernel_old_dev_t = uint
45
+ rbx.platform.typedef.__kernel_old_gid_t = ushort
46
+ rbx.platform.typedef.__kernel_old_time_t = long
47
+ rbx.platform.typedef.__kernel_old_uid_t = ushort
48
+ rbx.platform.typedef.__kernel_pid_t = int
49
+ rbx.platform.typedef.__kernel_ptrdiff_t = long
50
+ rbx.platform.typedef.__kernel_size_t = ulong
51
+ rbx.platform.typedef.__kernel_ssize_t = long
52
+ rbx.platform.typedef.__kernel_suseconds_t = long
53
+ rbx.platform.typedef.__kernel_time64_t = long_long
54
+ rbx.platform.typedef.__kernel_time_t = long
55
+ rbx.platform.typedef.__kernel_timer_t = int
56
+ rbx.platform.typedef.__kernel_uid16_t = ushort
57
+ rbx.platform.typedef.__kernel_uid32_t = uint
58
+ rbx.platform.typedef.__kernel_uid_t = uint
59
+ rbx.platform.typedef.__kernel_ulong_t = ulong
25
60
  rbx.platform.typedef.__key_t = int
26
61
  rbx.platform.typedef.__loff_t = long
27
62
  rbx.platform.typedef.__mode_t = uint
@@ -38,11 +73,14 @@ rbx.platform.typedef.__rusage_who_t = int
38
73
  rbx.platform.typedef.__sig_atomic_t = int
39
74
  rbx.platform.typedef.__socklen_t = uint
40
75
  rbx.platform.typedef.__ssize_t = long
76
+ rbx.platform.typedef.__suseconds64_t = long
41
77
  rbx.platform.typedef.__suseconds_t = long
42
78
  rbx.platform.typedef.__syscall_slong_t = long
43
79
  rbx.platform.typedef.__syscall_ulong_t = ulong
80
+ rbx.platform.typedef.__thrd_t = ulong
44
81
  rbx.platform.typedef.__time_t = long
45
82
  rbx.platform.typedef.__timer_t = pointer
83
+ rbx.platform.typedef.__tss_t = uint
46
84
  rbx.platform.typedef.__u_char = uchar
47
85
  rbx.platform.typedef.__u_int = uint
48
86
  rbx.platform.typedef.__u_long = ulong
@@ -53,6 +91,11 @@ rbx.platform.typedef.__uint16_t = ushort
53
91
  rbx.platform.typedef.__uint32_t = uint
54
92
  rbx.platform.typedef.__uint64_t = ulong
55
93
  rbx.platform.typedef.__uint8_t = uchar
94
+ rbx.platform.typedef.__uint_least16_t = ushort
95
+ rbx.platform.typedef.__uint_least32_t = uint
96
+ rbx.platform.typedef.__uint_least64_t = ulong
97
+ rbx.platform.typedef.__uint_least8_t = uchar
98
+ rbx.platform.typedef.__uintmax_t = ulong
56
99
  rbx.platform.typedef.__useconds_t = uint
57
100
  rbx.platform.typedef.blkcnt_t = long
58
101
  rbx.platform.typedef.blksize_t = int
@@ -65,11 +108,23 @@ rbx.platform.typedef.fsblkcnt_t = ulong
65
108
  rbx.platform.typedef.fsfilcnt_t = ulong
66
109
  rbx.platform.typedef.gid_t = uint
67
110
  rbx.platform.typedef.id_t = uint
111
+ rbx.platform.typedef.in_addr_t = uint
112
+ rbx.platform.typedef.in_port_t = ushort
68
113
  rbx.platform.typedef.ino_t = ulong
69
114
  rbx.platform.typedef.int16_t = short
70
115
  rbx.platform.typedef.int32_t = int
71
- rbx.platform.typedef.int64_t = long_long
116
+ rbx.platform.typedef.int64_t = long
72
117
  rbx.platform.typedef.int8_t = char
118
+ rbx.platform.typedef.int_fast16_t = long
119
+ rbx.platform.typedef.int_fast32_t = long
120
+ rbx.platform.typedef.int_fast64_t = long
121
+ rbx.platform.typedef.int_fast8_t = char
122
+ rbx.platform.typedef.int_least16_t = short
123
+ rbx.platform.typedef.int_least32_t = int
124
+ rbx.platform.typedef.int_least64_t = long
125
+ rbx.platform.typedef.int_least8_t = char
126
+ rbx.platform.typedef.intmax_t = long
127
+ rbx.platform.typedef.intptr_t = long
73
128
  rbx.platform.typedef.key_t = int
74
129
  rbx.platform.typedef.loff_t = long
75
130
  rbx.platform.typedef.mode_t = uint
@@ -79,6 +134,7 @@ rbx.platform.typedef.pid_t = int
79
134
  rbx.platform.typedef.pthread_key_t = uint
80
135
  rbx.platform.typedef.pthread_once_t = int
81
136
  rbx.platform.typedef.pthread_t = ulong
137
+ rbx.platform.typedef.ptrdiff_t = long
82
138
  rbx.platform.typedef.quad_t = long
83
139
  rbx.platform.typedef.register_t = long
84
140
  rbx.platform.typedef.rlim_t = ulong
@@ -93,12 +149,27 @@ rbx.platform.typedef.u_char = uchar
93
149
  rbx.platform.typedef.u_int = uint
94
150
  rbx.platform.typedef.u_int16_t = ushort
95
151
  rbx.platform.typedef.u_int32_t = uint
96
- rbx.platform.typedef.u_int64_t = ulong_long
152
+ rbx.platform.typedef.u_int64_t = ulong
97
153
  rbx.platform.typedef.u_int8_t = uchar
98
154
  rbx.platform.typedef.u_long = ulong
99
155
  rbx.platform.typedef.u_quad_t = ulong
100
156
  rbx.platform.typedef.u_short = ushort
101
157
  rbx.platform.typedef.uid_t = uint
102
158
  rbx.platform.typedef.uint = uint
159
+ rbx.platform.typedef.uint16_t = ushort
160
+ rbx.platform.typedef.uint32_t = uint
161
+ rbx.platform.typedef.uint64_t = ulong
162
+ rbx.platform.typedef.uint8_t = uchar
163
+ rbx.platform.typedef.uint_fast16_t = ulong
164
+ rbx.platform.typedef.uint_fast32_t = ulong
165
+ rbx.platform.typedef.uint_fast64_t = ulong
166
+ rbx.platform.typedef.uint_fast8_t = uchar
167
+ rbx.platform.typedef.uint_least16_t = ushort
168
+ rbx.platform.typedef.uint_least32_t = uint
169
+ rbx.platform.typedef.uint_least64_t = ulong
170
+ rbx.platform.typedef.uint_least8_t = uchar
171
+ rbx.platform.typedef.uintmax_t = ulong
172
+ rbx.platform.typedef.uintptr_t = ulong
103
173
  rbx.platform.typedef.ulong = ulong
104
174
  rbx.platform.typedef.ushort = ushort
175
+ rbx.platform.typedef.wchar_t = uint
data/lib/ffi/pointer.rb CHANGED
@@ -45,12 +45,12 @@ module FFI
45
45
  SIZE = Platform::ADDRESS_SIZE / 8 unless const_defined?(:SIZE)
46
46
 
47
47
  # Return the size of a pointer on the current platform, in bytes
48
- # @return [Numeric]
48
+ # @return [Integer]
49
49
  def self.size
50
50
  SIZE
51
51
  end unless respond_to?(:size)
52
52
 
53
- # @param [nil,Numeric] len length of string to return
53
+ # @param [nil,Integer] len length of string to return
54
54
  # @return [String]
55
55
  # Read pointer's contents as a string, or the first +len+ bytes of the
56
56
  # equivalent string if +len+ is not +nil+.
@@ -63,7 +63,7 @@ module FFI
63
63
  end
64
64
  end unless method_defined?(:read_string)
65
65
 
66
- # @param [Numeric] len length of string to return
66
+ # @param [Integer] len length of string to return
67
67
  # @return [String]
68
68
  # Read the first +len+ bytes of pointer's contents as a string.
69
69
  #
@@ -83,7 +83,7 @@ module FFI
83
83
  end unless method_defined?(:read_string_to_null)
84
84
 
85
85
  # @param [String] str string to write
86
- # @param [Numeric] len length of string to return
86
+ # @param [Integer] len length of string to return
87
87
  # @return [self]
88
88
  # Write +len+ first bytes of +str+ in pointer's contents.
89
89
  #
@@ -94,7 +94,7 @@ module FFI
94
94
  end unless method_defined?(:write_string_length)
95
95
 
96
96
  # @param [String] str string to write
97
- # @param [Numeric] len length of string to return
97
+ # @param [Integer] len length of string to return
98
98
  # @return [self]
99
99
  # Write +str+ in pointer's contents, or first +len+ bytes if
100
100
  # +len+ is not +nil+.
@@ -106,7 +106,7 @@ module FFI
106
106
 
107
107
  # @param [Type] type type of data to read from pointer's contents
108
108
  # @param [Symbol] reader method to send to +self+ to read +type+
109
- # @param [Numeric] length
109
+ # @param [Integer] length
110
110
  # @return [Array]
111
111
  # Read an array of +type+ of length +length+.
112
112
  # @example
data/lib/ffi/struct.rb CHANGED
@@ -41,12 +41,12 @@ module FFI
41
41
  class Struct
42
42
 
43
43
  # Get struct size
44
- # @return [Numeric]
44
+ # @return [Integer]
45
45
  def size
46
46
  self.class.size
47
47
  end
48
48
 
49
- # @return [Fixnum] Struct alignment
49
+ # @return [Integer] Struct alignment
50
50
  def alignment
51
51
  self.class.alignment
52
52
  end
@@ -87,13 +87,13 @@ module FFI
87
87
  end
88
88
 
89
89
  # Get struct size
90
- # @return [Numeric]
90
+ # @return [Integer]
91
91
  def self.size
92
92
  defined?(@layout) ? @layout.size : defined?(@size) ? @size : 0
93
93
  end
94
94
 
95
95
  # set struct size
96
- # @param [Numeric] size
96
+ # @param [Integer] size
97
97
  # @return [size]
98
98
  def self.size=(size)
99
99
  raise ArgumentError, "Size already set" if defined?(@size) || defined?(@layout)
@@ -35,13 +35,13 @@ module FFI
35
35
 
36
36
  class StructLayout
37
37
 
38
- # @return [Array<Array(Symbol, Numeric)>
38
+ # @return [Array<Array(Symbol, Integer)>
39
39
  # Get an array of tuples (field name, offset of the field).
40
40
  def offsets
41
41
  members.map { |m| [ m, self[m].offset ] }
42
42
  end
43
43
 
44
- # @return [Numeric]
44
+ # @return [Integer]
45
45
  # Get the offset of a field.
46
46
  def offset_of(field_name)
47
47
  self[field_name].offset
@@ -46,13 +46,13 @@ module FFI
46
46
  end
47
47
 
48
48
  # Set size attribute with +size+ only if +size+ is greater than attribute value.
49
- # @param [Numeric] size
49
+ # @param [Integer] size
50
50
  def size=(size)
51
51
  @size = size if size > @size
52
52
  end
53
53
 
54
54
  # Set alignment attribute with +align+ only if it is greater than attribute value.
55
- # @param [Numeric] align
55
+ # @param [Integer] align
56
56
  def alignment=(align)
57
57
  @alignment = align if align > @alignment
58
58
  @min_alignment = align
@@ -78,7 +78,7 @@ module FFI
78
78
  # @overload packed=(packed) Set alignment and packed attributes to
79
79
  # +packed+.
80
80
  #
81
- # @param [Fixnum] packed
81
+ # @param [Integer] packed
82
82
  #
83
83
  # @return [packed]
84
84
  # @overload packed=(packed) Set packed attribute.
@@ -116,7 +116,7 @@ module FFI
116
116
 
117
117
  # @param [String, Symbol] name name of the field
118
118
  # @param [Array, DataConverter, Struct, StructLayout::Field, Symbol, Type] type type of the field
119
- # @param [Numeric, nil] offset
119
+ # @param [Integer, nil] offset
120
120
  # @return [self]
121
121
  # Add a field to the builder.
122
122
  # @note Setting +offset+ to +nil+ or +-1+ is equivalent to +0+.
@@ -154,7 +154,7 @@ module FFI
154
154
 
155
155
  # @param name (see #add)
156
156
  # @param type (see #add)
157
- # @param [Numeric] count array length
157
+ # @param [Integer] count array length
158
158
  # @param offset (see #add)
159
159
  # @return (see #add)
160
160
  # Add an array as a field to the builder.
@@ -175,9 +175,9 @@ module FFI
175
175
 
176
176
  private
177
177
 
178
- # @param [Numeric] offset
179
- # @param [Numeric] align
180
- # @return [Numeric]
178
+ # @param [Integer] offset
179
+ # @param [Integer] align
180
+ # @return [Integer]
181
181
  def align(offset, align)
182
182
  align + ((offset - 1) & ~(align - 1));
183
183
  end