ffi 1.0.2-x86-mingw32 → 1.0.3-x86-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.

@@ -3,7 +3,7 @@ require 'mkmf'
3
3
  require 'rbconfig'
4
4
  dir_config("ffi_c")
5
5
 
6
- unless Config::CONFIG['host_os'] =~ /mswin32|mingw32/
6
+ unless RbConfig::CONFIG['host_os'] =~ /mswin32|mingw32/
7
7
  if pkg_config("libffi") || find_header("ffi.h", "/usr/local/include")
8
8
 
9
9
  # We need at least ffi_call and ffi_prep_closure
@@ -25,16 +25,16 @@ $defs << "-DRUBY_1_9" if RUBY_VERSION >= "1.9.0"
25
25
 
26
26
  create_header
27
27
 
28
- $CFLAGS << " -mwin32 " if Config::CONFIG['host_os'] =~ /cygwin/
28
+ $CFLAGS << " -mwin32 " if RbConfig::CONFIG['host_os'] =~ /cygwin/
29
29
  #$CFLAGS << " -Werror -Wunused -Wformat -Wimplicit -Wreturn-type "
30
30
 
31
31
  create_makefile("ffi_c")
32
32
  unless libffi_ok
33
33
  File.open("Makefile", "a") do |mf|
34
- mf.puts "LIBFFI_HOST=--host=#{Config::CONFIG['host_alias']}" if Config::CONFIG.has_key?("host_alias")
35
- if Config::CONFIG['host_os'].downcase =~ /darwin/
34
+ mf.puts "LIBFFI_HOST=--host=#{RbConfig::CONFIG['host_alias']}" if RbConfig::CONFIG.has_key?("host_alias")
35
+ if RbConfig::CONFIG['host_os'].downcase =~ /darwin/
36
36
  mf.puts "include ${srcdir}/libffi.darwin.mk"
37
- elsif Config::CONFIG['host_os'].downcase =~ /bsd/
37
+ elsif RbConfig::CONFIG['host_os'].downcase =~ /bsd/
38
38
  mf.puts '.include "${srcdir}/libffi.bsd.mk"'
39
39
  else
40
40
  mf.puts "include ${srcdir}/libffi.mk"
Binary file
@@ -10,7 +10,7 @@ describe "async callback" do
10
10
  attach_function :testAsyncCallback, [ AsyncIntCallback, :int ], :void, :blocking => true
11
11
  end
12
12
 
13
- unless RUBY_VERSION =~ /1.8/
13
+ # unless RUBY_VERSION =~ /1.8/
14
14
  it ":int (0x7fffffff) argument" do
15
15
  v = 0xdeadbeef
16
16
  called = false
@@ -19,5 +19,5 @@ describe "async callback" do
19
19
  called.should be_true
20
20
  v.should == 0x7fffffff
21
21
  end
22
- end
22
+ # end
23
23
  end
@@ -1,3 +1,19 @@
1
+ #
2
+ # This file is part of ruby-ffi.
3
+ #
4
+ # This code is free software: you can redistribute it and/or modify it under
5
+ # the terms of the GNU Lesser General Public License version 3 only, as
6
+ # published by the Free Software Foundation.
7
+ #
8
+ # This code is distributed in the hope that it will be useful, but WITHOUT
9
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11
+ # version 3 for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public License
14
+ # version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
15
+ #
16
+
1
17
  require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
2
18
 
3
19
  describe FFI::Function do
@@ -48,14 +64,12 @@ describe FFI::Function do
48
64
  foo.add(10, 10).should == 20
49
65
  end
50
66
  it 'can wrap a blocking function' do
51
- unless RUBY_VERSION =~ /1.8/
52
- fp = FFI::Function.new(:void, [ :int ], @libtest.find_function('testBlocking'), :blocking => true)
53
- time = Time.now
54
- threads = []
55
- threads << Thread.new { fp.call(2) }
56
- threads << Thread.new(time) { (Time.now - time).should < 1 }
57
- threads.each { |t| t.join }
58
- end
67
+ fp = FFI::Function.new(:void, [ :int ], @libtest.find_function('testBlocking'), :blocking => true)
68
+ time = Time.now
69
+ threads = []
70
+ threads << Thread.new { fp.call(2) }
71
+ threads << Thread.new(time) { (Time.now - time).should < 1 }
72
+ threads.each { |t| t.join }
59
73
  end
60
74
  it 'autorelease flag is set to true by default' do
61
75
  fp = FFI::Function.new(:int, [:int, :int], @libtest.find_function('testAdd'))
@@ -1,8 +1,25 @@
1
+ #
2
+ # This file is part of ruby-ffi.
3
+ #
4
+ # This code is free software: you can redistribute it and/or modify it under
5
+ # the terms of the GNU Lesser General Public License version 3 only, as
6
+ # published by the Free Software Foundation.
7
+ #
8
+ # This code is distributed in the hope that it will be useful, but WITHOUT
9
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11
+ # version 3 for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public License
14
+ # version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
15
+ #
1
16
  require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
2
17
  require 'delegate'
3
18
  require 'java' if RUBY_PLATFORM =~ /java/
4
19
 
5
- module LibTest
20
+ module PointerTestLib
21
+ extend FFI::Library
22
+ ffi_lib TestLibrary::PATH
6
23
  attach_function :ptr_ret_int32_t, [ :pointer, :int ], :int
7
24
  attach_function :ptr_from_address, [ FFI::Platform::ADDRESS_SIZE == 32 ? :uint : :ulong_long ], :pointer
8
25
  attach_function :ptr_set_pointer, [ :pointer, :int, :pointer ], :void
@@ -23,7 +40,7 @@ describe "Pointer" do
23
40
  magic = 0x12345678
24
41
  memory.put_int32(0, magic)
25
42
  tp = ToPtrTest.new(memory)
26
- LibTest.ptr_ret_int32_t(tp, 0).should == magic
43
+ PointerTestLib.ptr_ret_int32_t(tp, 0).should == magic
27
44
  end
28
45
  class PointerDelegate < DelegateClass(FFI::Pointer)
29
46
  def initialize(ptr)
@@ -38,53 +55,40 @@ describe "Pointer" do
38
55
  magic = 0x12345678
39
56
  memory.put_int32(0, magic)
40
57
  ptr = PointerDelegate.new(memory)
41
- LibTest.ptr_ret_int32_t(ptr, 0).should == magic
58
+ PointerTestLib.ptr_ret_int32_t(ptr, 0).should == magic
42
59
  end
43
60
  it "Fixnum cannot be used as a Pointer argument" do
44
- lambda { LibTest.ptr_ret_int32(0, 0) }.should raise_error
61
+ lambda { PointerTestLib.ptr_ret_int32(0, 0) }.should raise_error
45
62
  end
46
63
  it "Bignum cannot be used as a Pointer argument" do
47
- lambda { LibTest.ptr_ret_int32(0xfee1deadbeefcafebabe, 0) }.should raise_error
64
+ lambda { PointerTestLib.ptr_ret_int32(0xfee1deadbeefcafebabe, 0) }.should raise_error
48
65
  end
49
66
 
50
67
  describe "pointer type methods" do
51
68
 
52
- describe "#read_pointer" do
69
+ it "#read_pointer" do
53
70
  memory = FFI::MemoryPointer.new :pointer
54
- LibTest.ptr_set_pointer(memory, 0, LibTest.ptr_from_address(0xdeadbeef))
71
+ PointerTestLib.ptr_set_pointer(memory, 0, PointerTestLib.ptr_from_address(0xdeadbeef))
55
72
  memory.read_pointer.address.should == 0xdeadbeef
56
73
  end
57
74
 
58
- describe "#write_pointer" do
75
+ it "#write_pointer" do
59
76
  memory = FFI::MemoryPointer.new :pointer
60
- memory.write_pointer(LibTest.ptr_from_address(0xdeadbeef))
61
- LibTest.ptr_ret_pointer(memory, 0).address.should == 0xdeadbeef
77
+ memory.write_pointer(PointerTestLib.ptr_from_address(0xdeadbeef))
78
+ PointerTestLib.ptr_ret_pointer(memory, 0).address.should == 0xdeadbeef
62
79
  end
63
80
 
64
- describe "#read_array_of_pointer" do
81
+ it "#read_array_of_pointer" do
65
82
  values = [0x12345678, 0xfeedf00d, 0xdeadbeef]
66
83
  memory = FFI::MemoryPointer.new :pointer, values.size
67
84
  values.each_with_index do |address, j|
68
- LibTest.ptr_set_pointer(memory, j * FFI.type_size(:pointer), LibTest.ptr_from_address(address))
85
+ PointerTestLib.ptr_set_pointer(memory, j * FFI.type_size(:pointer), PointerTestLib.ptr_from_address(address))
69
86
  end
70
87
  array = memory.read_array_of_pointer(values.size)
71
88
  values.each_with_index do |address, j|
72
89
  array[j].address.should == address
73
90
  end
74
91
  end
75
-
76
- describe "#write_array_of_pointer" do
77
- values = [0x12345678, 0xfeedf00d, 0xdeadbeef]
78
- memory = FFI::MemoryPointer.new :pointer, values.size
79
- memory.write_array_of_pointer(values.map { |address| LibTest.ptr_from_address(address) })
80
- array = []
81
- values.each_with_index do |address, j|
82
- array << LibTest.ptr_ret_pointer(memory, j * FFI.type_size(:pointer))
83
- end
84
- values.each_with_index do |address, j|
85
- array[j].address.should == address
86
- end
87
- end
88
92
 
89
93
  end
90
94
 
@@ -145,7 +149,7 @@ describe "AutoPointer" do
145
149
  # note that if we called
146
150
  # AutoPointerTestHelper.method(:release).to_proc inline, we'd
147
151
  # have a reference to the pointer and it would never get GC'd.
148
- ap = AutoPointerSubclass.new(LibTest.ptr_from_address(magic))
152
+ ap = AutoPointerSubclass.new(PointerTestLib.ptr_from_address(magic))
149
153
  end
150
154
  AutoPointerTestHelper.gc_everything loop_count
151
155
  end
@@ -162,7 +166,7 @@ describe "AutoPointer" do
162
166
  AutoPointerTestHelper.should_receive(:release).at_least(loop_count-wiggle_room).times
163
167
  AutoPointerTestHelper.reset
164
168
  loop_count.times do
165
- ap = FFI::AutoPointer.new(LibTest.ptr_from_address(magic),
169
+ ap = FFI::AutoPointer.new(PointerTestLib.ptr_from_address(magic),
166
170
  AutoPointerTestHelper.finalizer)
167
171
  end
168
172
  AutoPointerTestHelper.gc_everything loop_count
@@ -172,7 +176,7 @@ describe "AutoPointer" do
172
176
  AutoPointerTestHelper.should_receive(:release).at_least(loop_count-wiggle_room).times
173
177
  AutoPointerTestHelper.reset
174
178
  loop_count.times do
175
- ap = FFI::AutoPointer.new(LibTest.ptr_from_address(magic),
179
+ ap = FFI::AutoPointer.new(PointerTestLib.ptr_from_address(magic),
176
180
  AutoPointerTestHelper.method(:release))
177
181
  end
178
182
  AutoPointerTestHelper.gc_everything loop_count
@@ -200,7 +204,7 @@ describe "AutoPointer#new" do
200
204
  lambda { FFI::AutoPointer.new(FFI::MemoryPointer.new(:int))}.should raise_error(::TypeError)
201
205
  end
202
206
  it "AutoPointer argument raises TypeError" do
203
- lambda { AutoPointerSubclass.new(AutoPointerSubclass.new(LibTest.ptr_from_address(0))) }.should raise_error(::TypeError)
207
+ lambda { AutoPointerSubclass.new(AutoPointerSubclass.new(PointerTestLib.ptr_from_address(0))) }.should raise_error(::TypeError)
204
208
  end
205
209
  it "Buffer argument raises TypeError" do
206
210
  lambda { FFI::AutoPointer.new(FFI::Buffer.new(:int))}.should raise_error(::TypeError)
@@ -1,6 +1,20 @@
1
+ #
2
+ # This file is part of ruby-ffi.
3
+ #
4
+ # This code is free software: you can redistribute it and/or modify it under
5
+ # the terms of the GNU Lesser General Public License version 3 only, as
6
+ # published by the Free Software Foundation.
7
+ #
8
+ # This code is distributed in the hope that it will be useful, but WITHOUT
9
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11
+ # version 3 for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public License
14
+ # version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
15
+ #
1
16
  require 'rubygems'
2
17
  require 'rbconfig'
3
- require 'spec'
4
18
 
5
19
  if RUBY_PLATFORM =~/java/
6
20
  libdir = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "lib"))
@@ -9,7 +23,7 @@ else
9
23
  $:.unshift File.join(File.dirname(__FILE__), "..", "..", "lib"),
10
24
  File.join(File.dirname(__FILE__), "..", "..", "build", "#{Config::CONFIG['host_cpu''arch']}", "ffi_c", RUBY_VERSION)
11
25
  end
12
- puts "loadpath=#{$:.join(':')}"
26
+ # puts "loadpath=#{$:.join(':')}"
13
27
  require "ffi"
14
28
 
15
29
  module TestLibrary
@@ -1,3 +1,19 @@
1
+ #
2
+ # This file is part of ruby-ffi.
3
+ #
4
+ # This code is free software: you can redistribute it and/or modify it under
5
+ # the terms of the GNU Lesser General Public License version 3 only, as
6
+ # published by the Free Software Foundation.
7
+ #
8
+ # This code is distributed in the hope that it will be useful, but WITHOUT
9
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11
+ # version 3 for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public License
14
+ # version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
15
+ #
16
+
1
17
  require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
2
18
  describe "String tests" do
3
19
  include FFI
@@ -10,14 +26,14 @@ describe "String tests" do
10
26
  attach_function :string_null, [ ], :string
11
27
  end
12
28
  it "MemoryPointer#get_string returns a tainted string" do
13
- mp = MemoryPointer.new 1024
29
+ mp = FFI::MemoryPointer.new 1024
14
30
  mp.put_string(0, "test\0")
15
31
  str = mp.get_string(0)
16
32
  str.tainted?.should == true
17
33
  end
18
34
  it "String returned by a method is tainted" do
19
- mp = MemoryPointer.new :pointer
20
- sp = MemoryPointer.new 1024
35
+ mp = FFI::MemoryPointer.new :pointer
36
+ sp = FFI::MemoryPointer.new 1024
21
37
  sp.put_string(0, "test")
22
38
  mp.put_pointer(0, sp)
23
39
  str = StrLibTest.ptr_ret_pointer(mp, 0)
@@ -45,9 +61,9 @@ describe "String tests" do
45
61
  end
46
62
  it "reads an array of strings until encountering a NULL pointer" do
47
63
  strings = ["foo", "bar", "baz", "testing", "ffi"]
48
- ptrary = MemoryPointer.new(:pointer, 6)
64
+ ptrary = FFI::MemoryPointer.new(:pointer, 6)
49
65
  ary = strings.inject([]) do |a, str|
50
- f = MemoryPointer.new(1024)
66
+ f = FFI::MemoryPointer.new(1024)
51
67
  f.put_string(0, str)
52
68
  a << f
53
69
  end
@@ -57,9 +73,9 @@ describe "String tests" do
57
73
  end
58
74
  it "reads an array of strings of the size specified, substituting nil when a pointer is NULL" do
59
75
  strings = ["foo", "bar", "baz", "testing", "ffi"]
60
- ptrary = MemoryPointer.new(:pointer, 6)
76
+ ptrary = FFI::MemoryPointer.new(:pointer, 6)
61
77
  ary = strings.inject([]) do |a, str|
62
- f = MemoryPointer.new(1024)
78
+ f = FFI::MemoryPointer.new(1024)
63
79
  f.put_string(0, str)
64
80
  a << f
65
81
  end
@@ -69,9 +85,9 @@ describe "String tests" do
69
85
  end
70
86
  it "reads an array of strings, taking a memory offset parameter" do
71
87
  strings = ["foo", "bar", "baz", "testing", "ffi"]
72
- ptrary = MemoryPointer.new(:pointer, 5)
88
+ ptrary = FFI::MemoryPointer.new(:pointer, 5)
73
89
  ary = strings.inject([]) do |a, str|
74
- f = MemoryPointer.new(1024)
90
+ f = FFI::MemoryPointer.new(1024)
75
91
  f.put_string(0, str)
76
92
  a << f
77
93
  end
@@ -80,9 +96,9 @@ describe "String tests" do
80
96
  end
81
97
  it "raises an IndexError when trying to read an array of strings out of bounds" do
82
98
  strings = ["foo", "bar", "baz", "testing", "ffi"]
83
- ptrary = MemoryPointer.new(:pointer, 5)
99
+ ptrary = FFI::MemoryPointer.new(:pointer, 5)
84
100
  ary = strings.inject([]) do |a, str|
85
- f = MemoryPointer.new(1024)
101
+ f = FFI::MemoryPointer.new(1024)
86
102
  f.put_string(0, str)
87
103
  a << f
88
104
  end
@@ -91,9 +107,9 @@ describe "String tests" do
91
107
  end
92
108
  it "raises an IndexError when trying to read an array of strings using a negative offset" do
93
109
  strings = ["foo", "bar", "baz", "testing", "ffi"]
94
- ptrary = MemoryPointer.new(:pointer, 5)
110
+ ptrary = FFI::MemoryPointer.new(:pointer, 5)
95
111
  ary = strings.inject([]) do |a, str|
96
- f = MemoryPointer.new(1024)
112
+ f = FFI::MemoryPointer.new(1024)
97
113
  f.put_string(0, str)
98
114
  a << f
99
115
  end
@@ -1,3 +1,18 @@
1
+ #
2
+ # This file is part of ruby-ffi.
3
+ #
4
+ # This code is free software: you can redistribute it and/or modify it under
5
+ # the terms of the GNU Lesser General Public License version 3 only, as
6
+ # published by the Free Software Foundation.
7
+ #
8
+ # This code is distributed in the hope that it will be useful, but WITHOUT
9
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11
+ # version 3 for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public License
14
+ # version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
15
+ #
1
16
  require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
2
17
 
3
18
  describe FFI::Struct, ' with an initialize function' do
@@ -20,7 +35,7 @@ describe FFI::ManagedStruct, ' with an initialize function' do
20
35
  layout :string, :string
21
36
  attr_accessor :magic
22
37
  def initialize
23
- super MemoryPointer.new(:pointer).put_int(0, 0x1234).get_pointer(0)
38
+ super FFI::MemoryPointer.new(:pointer).put_int(0, 0x1234).get_pointer(0)
24
39
  self.magic = 42
25
40
  end
26
41
  def self.release;end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 2
9
- version: 1.0.2
8
+ - 3
9
+ version: 1.0.3
10
10
  platform: x86-mingw32
11
11
  authors:
12
12
  - Wayne Meissner
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-17 00:00:00 +10:00
17
+ date: 2010-12-28 00:00:00 +10:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -345,6 +345,8 @@ files:
345
345
  - ext/ffi_c/StructByValue.c
346
346
  - ext/ffi_c/StructByValue.h
347
347
  - ext/ffi_c/StructLayout.c
348
+ - ext/ffi_c/Thread.c
349
+ - ext/ffi_c/Thread.h
348
350
  - ext/ffi_c/Type.c
349
351
  - ext/ffi_c/Type.h
350
352
  - ext/ffi_c/Types.c
@@ -431,10 +433,8 @@ required_ruby_version: !ruby/object:Gem::Requirement
431
433
  - - ">="
432
434
  - !ruby/object:Gem::Version
433
435
  segments:
434
- - 1
435
- - 9
436
- - 2
437
- version: 1.9.2
436
+ - 0
437
+ version: "0"
438
438
  required_rubygems_version: !ruby/object:Gem::Requirement
439
439
  none: false
440
440
  requirements: