ffi 1.9.8-x64-mingw32 → 1.9.9-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ffi might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZDUyOTczMzMxYTQ3M2UyY2M5NzRjZTc0OWMyODgwMDEzZjc4NDhmNw==
5
- data.tar.gz: !binary |-
6
- ZjBkOTBmNmI4MGY4ZGYzMjY3NGM5MGUzODFjYTIwNDE3OWJkNjE2OQ==
2
+ SHA1:
3
+ metadata.gz: fffe830558a1ebc0116476b9834bf81dd1b2f6ac
4
+ data.tar.gz: ef928981798bdb15c0938a8510b69891f3017d9e
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZmViZjliOTk4Yjg4N2NhYjVjM2RkMjFiZGYxNDc3MGQ3N2Y4M2JiNzE3OGNj
10
- OWZkNmZiMmUyNzM1ODBhYWFlYWQ0Yjk2N2Y2NjdlZDUxZTc2YTdiZDcxNTFm
11
- MDFiZGExOTIxODc4MWZkNDJmMjUwNGUyYmFjZGNjMzkwNGJmN2Y=
12
- data.tar.gz: !binary |-
13
- NDU4MDg0ZTY2ODA1NWM5ZTdhNDQyZmJjNDZiYTM4OTc5ZmVjYmFlYmUxMTE5
14
- OTg0NDE0MDBlNGE2ZTc3ZTczY2VkMjdlMDZlZDVkMTUxOWY4YjhiMTQyYWY2
15
- MGFmZGVjYzRkYzE0NzM3NGQxOWFiZGU5Zjk2OTI1NTEyZTZmYjU=
6
+ metadata.gz: 9c3cc4acdb4849495655b332cd08d4e590bcdc2c6807a4888b0f30de69b4a9ae0c5c006820aaeeb1fedcfa0465dee87aa683d7fdaaa7945b5eae0308a57f76bc
7
+ data.tar.gz: a6f04b206b152cd6a39d7c67f1624fa8488d4dedbe77facf69c582d32f5ffadfadbe8e3d9060731cf3c198b17f0223536d14bcaf5f803d1c274a74139f62c3eb
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'rubygems/tasks'
2
2
  require 'rbconfig'
3
3
  require 'rake/clean'
4
+ require File.expand_path("./lib/ffi/version")
4
5
 
5
6
  USE_RAKE_COMPILER = (RUBY_PLATFORM =~ /java/) ? false : true
6
7
  if USE_RAKE_COMPILER
@@ -13,11 +14,6 @@ require 'rbconfig'
13
14
  require 'rspec/core/rake_task'
14
15
  require 'rubygems/package_task'
15
16
 
16
- RSpec::Core::RakeTask.new(:spec => :compile) do |config|
17
- config.rspec_opts = YAML.load_file 'spec/spec.opts'
18
- end
19
-
20
-
21
17
  LIBEXT = case RbConfig::CONFIG['host_os'].downcase
22
18
  when /darwin/
23
19
  "dylib"
@@ -81,38 +77,31 @@ end
81
77
 
82
78
  TEST_DEPS = [ LIBTEST ]
83
79
  if RUBY_PLATFORM == "java"
84
- desc "Run all specs"
85
- task :specs, [:options] => TEST_DEPS do |t, args|
86
- sh %{#{Gem.ruby} -w -S rspec #{args.options || Dir["spec/ffi/*_spec.rb"].join(" ")} -fs --color}
87
- end
88
- desc "Run rubinius specs"
89
- task :rbxspecs => TEST_DEPS do
90
- sh %{#{Gem.ruby} -w -S rspec #{Dir["spec/ffi/rbx/*_spec.rb"].join(" ")} -fs --color}
80
+ RSpec::Core::RakeTask.new(:spec) do |config|
81
+ config.rspec_opts = YAML.load_file 'spec/spec.opts'
91
82
  end
92
83
  else
93
- TEST_DEPS.unshift :compile
94
- desc "Run all specs"
95
- task :specs, [:options] => TEST_DEPS do |t, args|
96
- ENV["MRI_FFI"] = "1"
97
- sh %{#{Gem.ruby} -w -Ilib -I#{BUILD_EXT_DIR} -S rspec #{args.options || Dir["spec/ffi/*_spec.rb"].join(" ")} -fs --color}
98
- end
99
- desc "Run rubinius specs"
100
- task :rbxspecs => TEST_DEPS do
101
- ENV["MRI_FFI"] = "1"
102
- sh %{#{Gem.ruby} -w -Ilib -I#{BUILD_EXT_DIR} -S rspec #{Dir["spec/ffi/rbx/*_spec.rb"].join(" ")} -fs --color}
84
+ RSpec::Core::RakeTask.new(:spec => :compile) do |config|
85
+ config.rspec_opts = YAML.load_file 'spec/spec.opts'
103
86
  end
87
+
88
+ TEST_DEPS.unshift :compile
104
89
  end
105
90
 
106
91
  desc "Build all packages"
107
92
  task :package => 'gem:package'
108
93
 
109
- CLOBBER.include 'build'
110
- CLOBBER.include FileList['lib/**/ffi_c.so']
111
- CLOBBER.include FileList["lib/**/ffi_c.#{RbConfig::CONFIG['DLEXT']}"]
112
94
  CLOBBER.include 'lib/ffi/types.conf'
113
- CLOBBER.include 'conftest.dSYM'
114
95
  CLOBBER.include 'pkg'
115
- CLOBBER.include 'spec/ffi/fixtures/libtest.dylib'
96
+
97
+ CLEAN.include 'build'
98
+ CLEAN.include 'conftest.dSYM'
99
+ CLEAN.include 'spec/ffi/fixtures/libtest.dylib'
100
+ CLEAN.include FileList["pkg/ffi-#{FFI::VERSION}-*-mingw32"]
101
+ CLEAN.include FileList["pkg/ffi-#{FFI::VERSION}-java"]
102
+ CLEAN.include FileList['lib/1.*']
103
+ CLEAN.include FileList['lib/2.*']
104
+ CLEAN.include 'bin'
116
105
 
117
106
  task :distclean => :clobber
118
107
 
@@ -185,27 +174,23 @@ if USE_RAKE_COMPILER
185
174
  ext.cross_platform = %w[i386-mingw32 x64-mingw32] # forces the Windows platform instead of the default one
186
175
  end
187
176
 
188
- task 'gem:win32' => ['gem:win32-x64', 'gem:win32-i386']
189
-
190
- task 'gem:win32-i386' do
191
- sh("rake cross native:i386-mingw32 gem RUBY_CC_VERSION='1.8.7:1.9.3:2.0.0:2.1.5:2.2.1'") || raise("win32-i386 build failed!")
192
- end
193
-
194
- task 'gem:win32-x64' do
195
- sh("rake cross native:x64-mingw32 gem RUBY_CC_VERSION='2.0.0:2.1.5:2.2.1'") || raise("win32-x64 build failed!")
196
- end
177
+ ENV['RUBY_CC_VERSION'] ||= '1.8.7:1.9.3:2.0.0:2.1.5:2.2.1'
197
178
 
198
- (ENV['RUBY_CC_VERSION'] || '1.8.7:1.9.3:2.0.0:2.1.5:2.2.1' ).to_s.split(':').each do |ruby_version|
179
+ ENV['RUBY_CC_VERSION'].to_s.split(':').each do |ruby_version|
199
180
  task "copy:ffi_c:i386-mingw32:#{ruby_version}" do |t|
200
181
  sh "i686-w64-mingw32-strip -S #{BUILD_DIR}/i386-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/ffi_c.so"
201
182
  end
202
- end
203
183
 
204
- (ENV['RUBY_CC_VERSION'] || '2.0.0:2.1.5:2.2.1' ).to_s.split(':').each do |ruby_version|
205
184
  task "copy:ffi_c:x64-mingw32:#{ruby_version}" do |t|
206
185
  sh "x86_64-w64-mingw32-strip -S #{BUILD_DIR}/x64-mingw32/stage/lib/#{ruby_version[/^\d+\.\d+/]}/ffi_c.so"
207
186
  end
208
187
  end
188
+
189
+ desc "build a windows gem without all the ceremony."
190
+ task "gem:windows" do
191
+ require "rake_compiler_dock"
192
+ RakeCompilerDock.sh "bundle && rake cross native gem MAKE='nice make -j`nproc`'"
193
+ end
209
194
  end
210
195
 
211
196
  Gem::Tasks.new do |t|
@@ -75,7 +75,7 @@ memptr_allocate(VALUE klass)
75
75
  * @param [Numeric] count number of cells in memory
76
76
  * @param [Boolean] clear set memory to all-zero if +true+
77
77
  * @return [self]
78
- * A new instance of FFI::MeoryPointer.
78
+ * A new instance of FFI::MemoryPointer.
79
79
  */
80
80
  static VALUE
81
81
  memptr_initialize(int argc, VALUE* argv, VALUE self)
@@ -132,12 +132,6 @@ rbffi_MethodHandle_CodeAddress(MethodHandle* handle)
132
132
  #ifndef CUSTOM_TRAMPOLINE
133
133
  static void attached_method_invoke(ffi_cif* cif, void* retval, METHOD_PARAMS parameters, void* user_data);
134
134
 
135
- static ffi_type* methodHandleParamTypes[] = {
136
- &ffi_type_sint,
137
- &ffi_type_pointer,
138
- &ffi_type_ulong,
139
- };
140
-
141
135
  static ffi_cif mh_cif;
142
136
 
143
137
  static bool
@@ -339,7 +333,12 @@ void
339
333
  rbffi_MethodHandle_Init(VALUE module)
340
334
  {
341
335
  #ifndef CUSTOM_TRAMPOLINE
342
- ffi_status ffiStatus;
336
+ ffi_status ffiStatus;
337
+ ffi_type* methodHandleParamTypes[] = {
338
+ &ffi_type_sint,
339
+ &ffi_type_pointer,
340
+ &ffi_type_ulong,
341
+ };
343
342
  #endif
344
343
 
345
344
  defaultClosurePool = rbffi_ClosurePool_New((int) trampoline_size(), prep_trampoline, NULL);
@@ -510,8 +510,8 @@ struct_layout_initialize(VALUE self, VALUE fields, VALUE size, VALUE align)
510
510
  static VALUE
511
511
  struct_layout_union_bang(VALUE self)
512
512
  {
513
- static const ffi_type *alignment_types[] = { &ffi_type_sint8, &ffi_type_sint16, &ffi_type_sint32, &ffi_type_sint64,
514
- &ffi_type_float, &ffi_type_double, &ffi_type_longdouble, NULL };
513
+ const ffi_type *alignment_types[] = { &ffi_type_sint8, &ffi_type_sint16, &ffi_type_sint32, &ffi_type_sint64,
514
+ &ffi_type_float, &ffi_type_double, &ffi_type_longdouble, NULL };
515
515
  StructLayout* layout;
516
516
  ffi_type *t = NULL;
517
517
  int count, i;
@@ -33,10 +33,11 @@ if !defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
33
33
  $defs << "-DHAVE_EXTCONF_H" if $defs.empty? # needed so create_header works
34
34
  $defs << "-DUSE_INTERNAL_LIBFFI" unless libffi_ok
35
35
  $defs << "-DRUBY_1_9" if RUBY_VERSION >= "1.9.0"
36
+ $defs << "-DFFI_BUILDING" if RbConfig::CONFIG['host_os'] =~ /mswin/ # for compatibility with newer libffi
36
37
 
37
38
  create_header
38
39
 
39
- $LOCAL_LIBS << " ./libffi/.libs/libffi_convenience.lib" if RbConfig::CONFIG['host_os'] =~ /mswin/
40
+ $LOCAL_LIBS << " ./libffi/.libs/libffi_convenience.lib" if !libffi_ok && RbConfig::CONFIG['host_os'] =~ /mswin/
40
41
 
41
42
  create_makefile("ffi_c")
42
43
  unless libffi_ok
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.required_ruby_version = '>= 1.8.7'
18
18
  s.add_development_dependency 'rake', '~> 10.1'
19
19
  s.add_development_dependency 'rake-compiler', '~> 0.9'
20
+ s.add_development_dependency 'rake-compiler-dock', '~> 0.3.1'
20
21
  s.add_development_dependency 'rspec', '~> 2.14.1'
21
22
  s.add_development_dependency 'rubygems-tasks', "~> 0.2.4"
22
23
  end
Binary file
Binary file
Binary file
data/lib/ffi.rb CHANGED
@@ -1,19 +1,7 @@
1
1
  if !defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
2
2
  Object.send(:remove_const, :FFI) if defined?(::FFI)
3
3
  begin
4
- if RUBY_VERSION =~ /1\.8/
5
- require '1.8/ffi_c'
6
- elsif RUBY_VERSION =~ /1\.9/
7
- require '1.9/ffi_c'
8
- elsif RUBY_VERSION =~ /2\.0/
9
- require '2.0/ffi_c'
10
- elsif RUBY_VERSION =~ /2\.1/
11
- require '2.1/ffi_c'
12
- elsif RUBY_VERSION =~ /2\.2/
13
- require '2.2/ffi_c'
14
- else
15
- require 'ffi_c'
16
- end
4
+ require RUBY_VERSION.split('.')[0, 2].join('.') + '/ffi_c'
17
5
  rescue Exception
18
6
  require 'ffi_c'
19
7
  end
@@ -161,9 +161,9 @@ module FFI
161
161
  # CallableReleaser is a {Releaser} used when an {AutoPointer} is defined with a
162
162
  # Proc or a Method.
163
163
  class CallableReleaser < Releaser
164
+ # Release +ptr+ by using Proc or Method defined at +ptr+ {AutoPointer#initialize initialization}.
164
165
  # @param [Pointer] ptr
165
166
  # @return [nil]
166
- # Release +ptr+ by using Proc or Method defined at +ptr+ {AutoPointer#initialize initialization}.
167
167
  def release(ptr)
168
168
  @proc.call(ptr)
169
169
  end
@@ -183,8 +183,8 @@ module FFI
183
183
  #
184
184
  # Override {DataConverter#from_native}.
185
185
  # @overload self.from_native(ptr, ctx)
186
- # @param [Pointer] ptr
187
- # @param ctx not used. Please set +nil+.
186
+ # @param [Pointer] ptr
187
+ # @param ctx not used. Please set +nil+.
188
188
  # @return [AutoPointer]
189
189
  def self.from_native(val, ctx)
190
190
  self.new(val)
@@ -85,6 +85,7 @@ module FFI
85
85
  include DataConverter
86
86
 
87
87
  attr_reader :tag
88
+ attr_reader :native_type
88
89
 
89
90
  # @overload initialize(info, tag=nil)
90
91
  # @param [nil, Enumerable] info
@@ -94,7 +95,7 @@ module FFI
94
95
  # @param [nil, Enumerable] info symbols and values for new Enum
95
96
  # @param [nil, Symbol] tag name of new Enum
96
97
  def initialize(*args)
97
- @native_type = args.shift if args.first.kind_of?(FFI::Type)
98
+ @native_type = args.first.kind_of?(FFI::Type) ? args.shift : Type::INT
98
99
  info, @tag = *args
99
100
  @kv_map = Hash.new
100
101
  unless info.nil?
@@ -149,12 +150,6 @@ module FFI
149
150
  alias to_h symbol_map
150
151
  alias to_hash symbol_map
151
152
 
152
- # Get native type of Enum
153
- # @return [Type]
154
- def native_type
155
- @native_type || Type::INT
156
- end
157
-
158
153
  # @param [Symbol, Integer, #to_int] val
159
154
  # @param ctx unused
160
155
  # @return [Integer] value of a enum symbol
@@ -292,24 +292,26 @@ module FFI
292
292
  end
293
293
 
294
294
  # @overload attach_variable(mname, cname, type)
295
- # @example
296
- # module Bar
297
- # extend FFI::Library
298
- # ffi_lib 'my_lib'
299
- # attach_variable :c_myvar, :myvar, :long
300
- # end
301
- # # now callable via Bar.c_myvar
295
+ # @param [#to_s] mname name of ruby method to attach as
296
+ # @param [#to_s] cname name of C variable to attach
297
+ # @param [DataConverter, Struct, Symbol, Type] type C variable's type
298
+ # @example
299
+ # module Bar
300
+ # extend FFI::Library
301
+ # ffi_lib 'my_lib'
302
+ # attach_variable :c_myvar, :myvar, :long
303
+ # end
304
+ # # now callable via Bar.c_myvar
302
305
  # @overload attach_variable(cname, type)
303
- # @example
304
- # module Bar
305
- # extend FFI::Library
306
- # ffi_lib 'my_lib'
307
- # attach_variable :myvar, :long
308
- # end
309
- # # now callable via Bar.myvar
310
- # @param [#to_s] mname name of ruby method to attach as
311
- # @param [#to_s] cname name of C variable to attach
312
- # @param [DataConverter, Struct, Symbol, Type] type C varaible's type
306
+ # @param [#to_s] mname name of ruby method to attach as
307
+ # @param [DataConverter, Struct, Symbol, Type] type C variable's type
308
+ # @example
309
+ # module Bar
310
+ # extend FFI::Library
311
+ # ffi_lib 'my_lib'
312
+ # attach_variable :myvar, :long
313
+ # end
314
+ # # now callable via Bar.myvar
313
315
  # @return [DynamicLibrary::Symbol]
314
316
  # @raise {FFI::NotFoundError} if +cname+ cannot be found in libraries
315
317
  #
@@ -360,10 +362,12 @@ module FFI
360
362
 
361
363
 
362
364
  # @overload callback(name, params, ret)
365
+ # @param name callback name to add to type map
366
+ # @param [Array] params array of parameters' types
367
+ # @param [DataConverter, Struct, Symbol, Type] ret callback return type
363
368
  # @overload callback(params, ret)
364
- # @param name callback name to add to type map
365
- # @param [Array] params array of parameters' types
366
- # @param [DataConverter, Struct, Symbol, Type] ret callback return type
369
+ # @param [Array] params array of parameters' types
370
+ # @param [DataConverter, Struct, Symbol, Type] ret callback return type
367
371
  # @return [FFI::CallbackInfo]
368
372
  def callback(*args)
369
373
  raise ArgumentError, "wrong number of arguments" if args.length < 2 || args.length > 3
@@ -388,10 +392,6 @@ module FFI
388
392
  cb
389
393
  end
390
394
 
391
- # @param [DataConverter, Symbol, Type] old
392
- # @param add
393
- # @param [] info
394
- # @return [FFI::Enum, FFI::Type]
395
395
  # Register or get an already registered type definition.
396
396
  #
397
397
  # To register a new type definition, +old+ should be a {FFI::Type}. +add+
@@ -404,6 +404,11 @@ module FFI
404
404
  # * in others cases, +info+ is used to create a named enum.
405
405
  #
406
406
  # If +old+ is a key for type map, #typedef get +old+ type definition.
407
+ #
408
+ # @param [DataConverter, Symbol, Type] old
409
+ # @param [Symbol] add
410
+ # @param [Symbol] info
411
+ # @return [FFI::Enum, FFI::Type]
407
412
  def typedef(old, add, info=nil)
408
413
  @ffi_typedefs = Hash.new unless defined?(@ffi_typedefs)
409
414
 
@@ -79,7 +79,7 @@ module FFI
79
79
  def self.is_os(os)
80
80
  OS == os
81
81
  end
82
-
82
+
83
83
  NAME = "#{ARCH}-#{OS}"
84
84
  IS_GNU = defined?(GNU_LIBC)
85
85
  IS_LINUX = is_os("linux")
@@ -87,12 +87,12 @@ module FFI
87
87
  IS_FREEBSD = is_os("freebsd")
88
88
  IS_NETBSD = is_os("netbsd")
89
89
  IS_OPENBSD = is_os("openbsd")
90
+ IS_SOLARIS = is_os("solaris")
90
91
  IS_WINDOWS = is_os("windows")
91
92
  IS_BSD = IS_MAC || IS_FREEBSD || IS_NETBSD || IS_OPENBSD
92
93
  CONF_DIR = File.join(File.dirname(__FILE__), 'platform', NAME)
93
- public
94
94
 
95
-
95
+ public
96
96
 
97
97
  LIBPREFIX = case OS
98
98
  when /windows/
@@ -143,6 +143,12 @@ module FFI
143
143
  IS_MAC
144
144
  end
145
145
 
146
+ # Test if current OS is Solaris (Sun OS)
147
+ # @return [Boolean]
148
+ def self.solaris?
149
+ IS_SOLARIS
150
+ end
151
+
146
152
  # Test if current OS is a unix OS
147
153
  # @return [Boolean]
148
154
  def self.unix?
@@ -341,7 +341,7 @@ module FFI
341
341
  # @raise if Ruby 1.8
342
342
  # Add hash +spec+ to +builder+.
343
343
  def hash_layout(builder, spec)
344
- raise "Ruby version not supported" if RUBY_VERSION =~ /1.8.*/
344
+ raise "Ruby version not supported" if RUBY_VERSION =~ /1\.8\.*/
345
345
  spec[0].each do |name, type|
346
346
  builder.add name, find_field_type(type), nil
347
347
  end
@@ -30,12 +30,12 @@
30
30
  #
31
31
 
32
32
  module FFI
33
-
33
+
34
34
  # Build a {StructLayout struct layout}.
35
35
  class StructLayoutBuilder
36
36
  attr_reader :size
37
37
  attr_reader :alignment
38
-
38
+
39
39
  def initialize
40
40
  @size = 0
41
41
  @alignment = 1
@@ -45,42 +45,47 @@ module FFI
45
45
  @fields = Array.new
46
46
  end
47
47
 
48
- # @param [Numeric] size
49
48
  # Set size attribute with +size+ only if +size+ is greater than attribute value.
49
+ # @param [Numeric] size
50
50
  def size=(size)
51
51
  @size = size if size > @size
52
52
  end
53
53
 
54
- # @param [Numeric] alignment
55
- # Set alignment attribute with +alignment+ only if it is greater than attribute value.
54
+ # Set alignment attribute with +align+ only if it is greater than attribute value.
55
+ # @param [Numeric] align
56
56
  def alignment=(align)
57
57
  @alignment = align if align > @alignment
58
58
  @min_alignment = align
59
59
  end
60
60
 
61
- # @param [Boolean] is_union
62
- # @return [is_union]
63
61
  # Set union attribute.
64
62
  # Set to +true+ to build a {Union} instead of a {Struct}.
63
+ # @param [Boolean] is_union
64
+ # @return [is_union]
65
65
  def union=(is_union)
66
66
  @union = is_union
67
67
  end
68
68
 
69
- # @return [Boolean]
70
69
  # Building a {Union} or a {Struct} ?
70
+ #
71
+ # @return [Boolean]
72
+ #
71
73
  def union?
72
74
  @union
73
75
  end
74
76
 
75
77
  # Set packed attribute
76
- # @overload packed=(packed)
77
- # @param [Fixnum] packed
78
- # @return [packed]
79
- # Set alignment and packed attributes to +packed+.
80
- # @overload packed=(packed)
81
- # @param packed
82
- # @return [0,1]
83
- # Set packed attribute.
78
+ # @overload packed=(packed) Set alignment and packed attributes to
79
+ # +packed+.
80
+ #
81
+ # @param [Fixnum] packed
82
+ #
83
+ # @return [packed]
84
+ # @overload packed=(packed) Set packed attribute.
85
+ # @param packed
86
+ #
87
+ # @return [0,1]
88
+ #
84
89
  def packed=(packed)
85
90
  if packed.is_a?(Fixnum)
86
91
  @alignment = packed
@@ -139,7 +144,7 @@ module FFI
139
144
  def add_field(name, type, offset = nil)
140
145
  add(name, type, offset)
141
146
  end
142
-
147
+
143
148
  # @param (see #add)
144
149
  # @return (see #add)
145
150
  # Add a struct as a field to the builder.
@@ -162,14 +167,14 @@ module FFI
162
167
  def build
163
168
  # Add tail padding if the struct is not packed
164
169
  size = @packed ? @size : align(@size, @alignment)
165
-
170
+
166
171
  layout = StructLayout.new(@fields, size, @alignment)
167
172
  layout.__union! if @union
168
173
  layout
169
174
  end
170
175
 
171
176
  private
172
-
177
+
173
178
  # @param [Numeric] offset
174
179
  # @param [Numeric] align
175
180
  # @return [Numeric]
@@ -155,7 +155,7 @@ module FFI
155
155
  native_type Type::POINTER
156
156
 
157
157
  # @param [Pointer] val
158
- # @param [] ctx
158
+ # @param ctx
159
159
  # @return [Array(String, Pointer)]
160
160
  # Returns a [ String, Pointer ] tuple so the C memory for the string can be freed
161
161
  def self.from_native(val, ctx)
@@ -1,4 +1,4 @@
1
1
  module FFI
2
- VERSION = '1.9.8'
2
+ VERSION = '1.9.9'
3
3
  end
4
4
 
@@ -38,7 +38,8 @@ describe "Managed Struct" do
38
38
  expect(ClassWithSelfRef.new(ManagedStructTestLib.ptr_from_address(0x12345678)).class).to eq(ClassWithSelfRef)
39
39
  end
40
40
 
41
- it "should release memory properly" do
41
+ # see #427
42
+ it "should release memory properly", :broken => true do
42
43
  class PleaseReleaseMe < FFI::ManagedStruct
43
44
  layout :i, :int
44
45
  @@count = 0
@@ -170,7 +170,8 @@ describe "AutoPointer" do
170
170
  def self.release(ptr); end
171
171
  end
172
172
 
173
- it "cleanup via default release method" do
173
+ # see #427
174
+ it "cleanup via default release method", :broken => true do
174
175
  expect(AutoPointerSubclass).to receive(:release).at_least(loop_count-wiggle_room).times
175
176
  AutoPointerTestHelper.reset
176
177
  loop_count.times do
@@ -182,7 +183,8 @@ describe "AutoPointer" do
182
183
  AutoPointerTestHelper.gc_everything loop_count
183
184
  end
184
185
 
185
- it "cleanup when passed a proc" do
186
+ # see #427
187
+ it "cleanup when passed a proc", :broken => true do
186
188
  # NOTE: passing a proc is touchy, because it's so easy to create a memory leak.
187
189
  #
188
190
  # specifically, if we made an inline call to
@@ -200,7 +202,8 @@ describe "AutoPointer" do
200
202
  AutoPointerTestHelper.gc_everything loop_count
201
203
  end
202
204
 
203
- it "cleanup when passed a method" do
205
+ # see #427
206
+ it "cleanup when passed a method", :broken => true do
204
207
  expect(AutoPointerTestHelper).to receive(:release).at_least(loop_count-wiggle_room).times
205
208
  AutoPointerTestHelper.reset
206
209
  loop_count.times do
@@ -25,7 +25,7 @@ describe FFI::Library, "#attach_function" do
25
25
 
26
26
  it "correctly populates a struct for gettimeofday" do
27
27
  t = Timeval.new
28
- time = LibC.gettimeofday(t.pointer, nil)
28
+ LibC.gettimeofday(t.pointer, nil)
29
29
  expect(t[:tv_sec]).to be_kind_of(Numeric)
30
30
  expect(t[:tv_usec]).to be_kind_of(Numeric)
31
31
  end
@@ -7,6 +7,10 @@ require 'rbconfig'
7
7
  require 'fileutils'
8
8
  require 'ffi'
9
9
 
10
+ RSpec.configure do |c|
11
+ c.filter_run_excluding :broken => true
12
+ end
13
+
10
14
  CPU = case RbConfig::CONFIG['host_cpu'].downcase
11
15
  when /i[3456]86/
12
16
  # Darwin always reports i686, even when running in 64bit mode
@@ -53,13 +57,7 @@ def compile_library(path, lib)
53
57
 
54
58
  dir = File.expand_path(path, File.dirname(__FILE__))
55
59
  lib = "#{dir}/#{lib}"
56
- if !File.exists?(lib)
57
- ldshared = RbConfig::CONFIG["LDSHARED"] || "clang -dynamic -bundle"
58
- libs = RbConfig::CONFIG["LIBS"]
59
- dldflags = RbConfig::CONFIG["DLDFLAGS"] || "-Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress"
60
-
61
- puts Dir.pwd, dir, File.dirname(__FILE__)
62
-
60
+ if !File.exist?(lib)
63
61
  output = nil
64
62
  FileUtils.cd(dir) do
65
63
  output = system(*%{#{system('which gmake >/dev/null') && 'gmake' || 'make'} CPU=#{CPU} OS=#{OS} }.tap{|x| puts x.inspect})
@@ -7,6 +7,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
7
7
 
8
8
  describe "Struct aligns fields correctly" do
9
9
  it "char, followed by an int" do
10
+ pending("not supported in 1.8") if RUBY_VERSION =~ /1.8.*/
10
11
  class CIStruct < FFI::Struct
11
12
  layout :c => :char, :i => :int
12
13
  end
@@ -14,6 +15,7 @@ describe "Struct aligns fields correctly" do
14
15
  end
15
16
 
16
17
  it "short, followed by an int" do
18
+ pending("not supported in 1.8") if RUBY_VERSION =~ /1.8.*/
17
19
  class SIStruct < FFI::Struct
18
20
  layout :s => :short, :i => :int
19
21
  end
@@ -21,6 +23,7 @@ describe "Struct aligns fields correctly" do
21
23
  end
22
24
 
23
25
  it "int, followed by an int" do
26
+ pending("not supported in 1.8") if RUBY_VERSION =~ /1.8.*/
24
27
  class IIStruct < FFI::Struct
25
28
  layout :i1 => :int, :i => :int
26
29
  end
@@ -28,6 +31,7 @@ describe "Struct aligns fields correctly" do
28
31
  end
29
32
 
30
33
  it "long long, followed by an int" do
34
+ pending("not supported in 1.8") if RUBY_VERSION =~ /1.8.*/
31
35
  class LLIStruct < FFI::Struct
32
36
  layout :l => :long_long, :i => :int
33
37
  end
@@ -102,7 +106,7 @@ describe "Struct tests" do
102
106
  smp = FFI::MemoryPointer.new :pointer
103
107
  s = PointerMember.new smp
104
108
  expect { s[:pointer] = s }.not_to raise_error Exception
105
- expect { foo = s[:pointer] }.not_to raise_error Exception
109
+ expect { s[:pointer].nil? }.not_to raise_error Exception
106
110
  end
107
111
 
108
112
  it "Struct#[:pointer]=nil" do
@@ -1,3 +1,4 @@
1
1
  --color
2
+ -w
2
3
  --format
3
4
  documentation
metadata CHANGED
@@ -1,77 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.8
4
+ version: 1.9.9
5
5
  platform: x64-mingw32
6
6
  authors:
7
7
  - Wayne Meissner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-16 00:00:00.000000000 Z
11
+ date: 2015-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: !binary |-
20
- MTAuMQ==
19
+ version: '10.1'
21
20
  type: :development
22
21
  prerelease: false
23
22
  version_requirements: !ruby/object:Gem::Requirement
24
23
  requirements:
25
- - - ~>
24
+ - - "~>"
26
25
  - !ruby/object:Gem::Version
27
- version: !binary |-
28
- MTAuMQ==
26
+ version: '10.1'
29
27
  - !ruby/object:Gem::Dependency
30
28
  name: rake-compiler
31
29
  requirement: !ruby/object:Gem::Requirement
32
30
  requirements:
33
- - - ~>
31
+ - - "~>"
34
32
  - !ruby/object:Gem::Version
35
33
  version: '0.9'
36
34
  type: :development
37
35
  prerelease: false
38
36
  version_requirements: !ruby/object:Gem::Requirement
39
37
  requirements:
40
- - - ~>
38
+ - - "~>"
41
39
  - !ruby/object:Gem::Version
42
40
  version: '0.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake-compiler-dock
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.3.1
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.3.1
43
55
  - !ruby/object:Gem::Dependency
44
56
  name: rspec
45
57
  requirement: !ruby/object:Gem::Requirement
46
58
  requirements:
47
- - - ~>
59
+ - - "~>"
48
60
  - !ruby/object:Gem::Version
49
- version: !binary |-
50
- Mi4xNC4x
61
+ version: 2.14.1
51
62
  type: :development
52
63
  prerelease: false
53
64
  version_requirements: !ruby/object:Gem::Requirement
54
65
  requirements:
55
- - - ~>
66
+ - - "~>"
56
67
  - !ruby/object:Gem::Version
57
- version: !binary |-
58
- Mi4xNC4x
68
+ version: 2.14.1
59
69
  - !ruby/object:Gem::Dependency
60
70
  name: rubygems-tasks
61
71
  requirement: !ruby/object:Gem::Requirement
62
72
  requirements:
63
- - - ~>
73
+ - - "~>"
64
74
  - !ruby/object:Gem::Version
65
- version: !binary |-
66
- MC4yLjQ=
75
+ version: 0.2.4
67
76
  type: :development
68
77
  prerelease: false
69
78
  version_requirements: !ruby/object:Gem::Requirement
70
79
  requirements:
71
- - - ~>
80
+ - - "~>"
72
81
  - !ruby/object:Gem::Version
73
- version: !binary |-
74
- MC4yLjQ=
82
+ version: 0.2.4
75
83
  description: Ruby FFI library
76
84
  email: wmeissner@gmail.com
77
85
  executables: []
@@ -545,23 +553,23 @@ licenses:
545
553
  metadata: {}
546
554
  post_install_message:
547
555
  rdoc_options:
548
- - --exclude=ext/ffi_c/.*\.o$
549
- - --exclude=ffi_c\.(bundle|so)$
556
+ - "--exclude=ext/ffi_c/.*\\.o$"
557
+ - "--exclude=ffi_c\\.(bundle|so)$"
550
558
  require_paths:
551
559
  - lib
552
560
  required_ruby_version: !ruby/object:Gem::Requirement
553
561
  requirements:
554
- - - ! '>='
562
+ - - ">="
555
563
  - !ruby/object:Gem::Version
556
564
  version: 1.8.7
557
565
  required_rubygems_version: !ruby/object:Gem::Requirement
558
566
  requirements:
559
- - - ! '>='
567
+ - - ">="
560
568
  - !ruby/object:Gem::Version
561
569
  version: '0'
562
570
  requirements: []
563
571
  rubyforge_project:
564
- rubygems_version: 2.4.3
572
+ rubygems_version: 2.4.8
565
573
  signing_key:
566
574
  specification_version: 4
567
575
  summary: Ruby FFI