ffi 1.2.1 → 1.3.0

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.

Files changed (67) hide show
  1. data/README.md +10 -5
  2. data/ext/ffi_c/ArrayType.c +6 -2
  3. data/ext/ffi_c/Buffer.c +3 -1
  4. data/ext/ffi_c/Call.c +12 -21
  5. data/ext/ffi_c/FunctionInfo.c +27 -2
  6. data/ext/ffi_c/MappedType.c +1 -2
  7. data/ext/ffi_c/MemoryPointer.c +35 -4
  8. data/ext/ffi_c/Pointer.c +5 -4
  9. data/ext/ffi_c/Struct.c +125 -8
  10. data/ext/ffi_c/StructByReference.c +33 -0
  11. data/ext/ffi_c/StructByValue.c +2 -2
  12. data/ext/ffi_c/StructLayout.c +135 -1
  13. data/ext/ffi_c/Type.c +1 -0
  14. data/ext/ffi_c/extconf.rb +1 -1
  15. data/ffi.gemspec +1 -1
  16. data/lib/ffi.rb +2 -1
  17. data/lib/ffi/library.rb +2 -0
  18. data/lib/ffi/managedstruct.rb +37 -37
  19. data/lib/ffi/struct.rb +74 -1
  20. data/lib/ffi/struct_layout_builder.rb +50 -1
  21. data/lib/ffi/tools/generator.rb +2 -0
  22. data/lib/ffi/tools/generator_task.rb +1 -0
  23. data/lib/ffi/tools/types_generator.rb +2 -0
  24. data/libtest/Benchmark.c +1 -15
  25. data/libtest/BoolTest.c +2 -16
  26. data/libtest/BufferTest.c +3 -17
  27. data/libtest/ClosureTest.c +1 -15
  28. data/libtest/EnumTest.c +1 -15
  29. data/libtest/FunctionTest.c +2 -16
  30. data/libtest/GlobalVariable.c +2 -16
  31. data/libtest/LastErrorTest.c +2 -16
  32. data/libtest/NumberTest.c +1 -15
  33. data/libtest/PointerTest.c +1 -15
  34. data/libtest/ReferenceTest.c +1 -15
  35. data/libtest/StringTest.c +1 -15
  36. data/libtest/StructTest.c +1 -15
  37. data/libtest/UnionTest.c +1 -15
  38. data/libtest/VariadicTest.c +2 -16
  39. data/spec/ffi/async_callback_spec.rb +3 -14
  40. data/spec/ffi/bool_spec.rb +7 -18
  41. data/spec/ffi/buffer_spec.rb +26 -37
  42. data/spec/ffi/callback_spec.rb +96 -107
  43. data/spec/ffi/custom_param_type.rb +2 -13
  44. data/spec/ffi/custom_type_spec.rb +1 -12
  45. data/spec/ffi/dup_spec.rb +7 -18
  46. data/spec/ffi/enum_spec.rb +128 -139
  47. data/spec/ffi/errno_spec.rb +2 -13
  48. data/spec/ffi/ffi_spec.rb +4 -15
  49. data/spec/ffi/function_spec.rb +6 -17
  50. data/spec/ffi/library_spec.rb +26 -26
  51. data/spec/ffi/long_double.rb +1 -12
  52. data/spec/ffi/managed_struct_spec.rb +3 -18
  53. data/spec/ffi/number_spec.rb +32 -43
  54. data/spec/ffi/pointer_spec.rb +7 -22
  55. data/spec/ffi/rbx/memory_pointer_spec.rb +17 -17
  56. data/spec/ffi/rbx/struct_spec.rb +2 -2
  57. data/spec/ffi/spec_helper.rb +10 -12
  58. data/spec/ffi/string_spec.rb +9 -20
  59. data/spec/ffi/strptr_spec.rb +2 -13
  60. data/spec/ffi/struct_callback_spec.rb +3 -14
  61. data/spec/ffi/struct_initialize_spec.rb +3 -14
  62. data/spec/ffi/struct_packed_spec.rb +7 -18
  63. data/spec/ffi/struct_spec.rb +93 -104
  64. data/spec/ffi/typedef_spec.rb +5 -16
  65. data/spec/ffi/union_spec.rb +4 -15
  66. data/spec/ffi/variadic_spec.rb +7 -18
  67. metadata +73 -58
@@ -1,17 +1,6 @@
1
1
  #
2
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/>.
3
+ # For licensing, see LICENSE.SPECS
15
4
  #
16
5
 
17
6
  require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
@@ -23,7 +12,7 @@ describe "Custom type definitions" do
23
12
  typedef :uint, :fubar_t
24
13
  attach_function :ret_u32, [ :fubar_t ], :fubar_t
25
14
  end
26
- CustomTypedef.ret_u32(0x12345678).should eq 0x12345678
15
+ CustomTypedef.ret_u32(0x12345678).should == 0x12345678
27
16
  end
28
17
  it "variadic invoker with custom typedef" do
29
18
  module VariadicCustomTypedef
@@ -34,7 +23,7 @@ describe "Custom type definitions" do
34
23
  end
35
24
  buf = FFI::Buffer.new :uint, 10
36
25
  VariadicCustomTypedef.pack_varargs(buf, "i", :fubar_t, 0x12345678)
37
- buf.get_int64(0).should eq 0x12345678
26
+ buf.get_int64(0).should == 0x12345678
38
27
  end
39
28
  it "Callback with custom typedef parameter" do
40
29
  module CallbackCustomTypedef
@@ -46,7 +35,7 @@ describe "Custom type definitions" do
46
35
  end
47
36
  i = 0
48
37
  CallbackCustomTypedef.testCallbackU32rV(0xdeadbeef) { |v| i = v }
49
- i.should eq 0xdeadbeef
38
+ i.should == 0xdeadbeef
50
39
  end
51
40
  module StructCustomTypedef
52
41
  extend FFI::Library
@@ -59,7 +48,7 @@ describe "Custom type definitions" do
59
48
  it "Struct with custom typedef field" do
60
49
  s = StructCustomTypedef::S.new
61
50
  s[:a] = 0x12345678
62
- s.pointer.get_uint(0).should eq 0x12345678
51
+ s.pointer.get_uint(0).should == 0x12345678
63
52
  end
64
53
 
65
54
  it "attach_function after a typedef should not reject normal types" do
@@ -1,17 +1,6 @@
1
1
  #
2
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/>.
3
+ # For licensing, see LICENSE.SPECS
15
4
  #
16
5
 
17
6
  require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
@@ -56,7 +45,7 @@ describe 'Union' do
56
45
  if k == 'f32' or k == 'f64'
57
46
  (@u[type[1]] - LibTest.send("union_align_#{k}", @u.to_ptr)).abs.should < 0.00001
58
47
  else
59
- @u[type[1]].should eq LibTest.send("union_align_#{k}", @u.to_ptr)
48
+ @u[type[1]].should == LibTest.send("union_align_#{k}", @u.to_ptr)
60
49
  end
61
50
  end
62
51
  end
@@ -66,11 +55,11 @@ describe 'Union' do
66
55
  if k == 'f32' or k == 'f64'
67
56
  (@u[type[1]] - type[2]).abs.should < 0.00001
68
57
  else
69
- @u[type[1]].should eq type[2]
58
+ @u[type[1]].should == type[2]
70
59
  end
71
60
  end
72
61
  end
73
62
  it 'should return a size equals to the size of the biggest field' do
74
- LibTest::TestUnion.size.should eq LibTest.union_size
63
+ LibTest::TestUnion.size.should == LibTest.union_size
75
64
  end
76
65
  end
@@ -1,17 +1,6 @@
1
1
  #
2
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/>.
3
+ # For licensing, see LICENSE.SPECS
15
4
  #
16
5
 
17
6
  require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
@@ -25,28 +14,28 @@ describe "Function with variadic arguments" do
25
14
  it "call variadic with (:char (#{i})) argument" do
26
15
  buf = FFI::Buffer.new :long_long
27
16
  LibTest.pack_varargs(buf, "c", :char, i)
28
- buf.get_int64(0).should eq i
17
+ buf.get_int64(0).should == i
29
18
  end
30
19
  end
31
20
  [ 0, 0x7f, 0x80, 0xff ].each do |i|
32
21
  it "call variadic with (:uchar (#{i})) argument" do
33
22
  buf = FFI::Buffer.new :long_long
34
23
  LibTest.pack_varargs(buf, "C", :uchar, i)
35
- buf.get_int64(0).should eq i
24
+ buf.get_int64(0).should == i
36
25
  end
37
26
  end
38
27
  [ 0, 1.234567, 9.87654321 ].each do |v|
39
28
  it "call variadic with (:float (#{v})) argument" do
40
29
  buf = FFI::Buffer.new :long_long
41
30
  LibTest.pack_varargs(buf, "f", :float, v.to_f)
42
- buf.get_float64(0).should eq v
31
+ buf.get_float64(0).should == v
43
32
  end
44
33
  end
45
34
  [ 0, 1.234567, 9.87654321 ].each do |v|
46
35
  it "call variadic with (:double (#{v})) argument" do
47
36
  buf = FFI::Buffer.new :long_long
48
37
  LibTest.pack_varargs(buf, "f", :double, v.to_f)
49
- buf.get_float64(0).should eq v
38
+ buf.get_float64(0).should == v
50
39
  end
51
40
  end
52
41
 
@@ -73,9 +62,9 @@ describe "Function with variadic arguments" do
73
62
 
74
63
  def verify(p, off, v)
75
64
  if v.kind_of?(Float)
76
- p.get_float64(off).should eq v
65
+ p.get_float64(off).should == v
77
66
  else
78
- p.get_int64(off).should eq v
67
+ p.get_int64(off).should == v
79
68
  end
80
69
  end
81
70
 
metadata CHANGED
@@ -1,71 +1,75 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ffi
3
- version: !ruby/object:Gem::Version
4
- version: 1.2.1
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
5
  prerelease:
6
+ segments:
7
+ - 1
8
+ - 3
9
+ - 0
10
+ version: 1.3.0
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Wayne Meissner
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2013-01-08 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: rake
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :development
17
+
18
+ date: 2013-01-08 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
23
21
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
22
+ requirement: &id001 !ruby/object:Gem::Requirement
25
23
  none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: rake-compiler
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: 0.6.0
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 3
28
+ segments:
29
+ - 0
30
+ version: "0"
38
31
  type: :development
32
+ name: rake
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
39
35
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
36
+ requirement: &id002 !ruby/object:Gem::Requirement
41
37
  none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ hash: 7
42
+ segments:
43
+ - 0
44
+ - 6
45
+ - 0
45
46
  version: 0.6.0
46
- - !ruby/object:Gem::Dependency
47
- name: rspec
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
47
  type: :development
48
+ name: rake-compiler
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
55
51
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
52
+ requirement: &id003 !ruby/object:Gem::Requirement
57
53
  none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ type: :development
62
+ name: rspec
63
+ version_requirements: *id003
62
64
  description: Ruby FFI library
63
65
  email: wmeissner@gmail.com
64
66
  executables: []
65
- extensions:
67
+
68
+ extensions:
66
69
  - ext/ffi_c/extconf.rb
67
70
  extra_rdoc_files: []
68
- files:
71
+
72
+ files:
69
73
  - ffi.gemspec
70
74
  - History.txt
71
75
  - LICENSE
@@ -501,29 +505,40 @@ files:
501
505
  - libtest/UnionTest.c
502
506
  - libtest/VariadicTest.c
503
507
  homepage: http://wiki.github.com/ffi/ffi
504
- licenses:
508
+ licenses:
505
509
  - LGPL-3
506
510
  post_install_message:
507
511
  rdoc_options: []
508
- require_paths:
512
+
513
+ require_paths:
509
514
  - lib
510
515
  - ext/ffi_c
511
- required_ruby_version: !ruby/object:Gem::Requirement
516
+ required_ruby_version: !ruby/object:Gem::Requirement
512
517
  none: false
513
- requirements:
514
- - - ! '>='
515
- - !ruby/object:Gem::Version
518
+ requirements:
519
+ - - ">="
520
+ - !ruby/object:Gem::Version
521
+ hash: 57
522
+ segments:
523
+ - 1
524
+ - 8
525
+ - 7
516
526
  version: 1.8.7
517
- required_rubygems_version: !ruby/object:Gem::Requirement
527
+ required_rubygems_version: !ruby/object:Gem::Requirement
518
528
  none: false
519
- requirements:
520
- - - ! '>='
521
- - !ruby/object:Gem::Version
522
- version: '0'
529
+ requirements:
530
+ - - ">="
531
+ - !ruby/object:Gem::Version
532
+ hash: 3
533
+ segments:
534
+ - 0
535
+ version: "0"
523
536
  requirements: []
537
+
524
538
  rubyforge_project:
525
539
  rubygems_version: 1.8.24
526
540
  signing_key:
527
541
  specification_version: 3
528
542
  summary: Ruby FFI
529
543
  test_files: []
544
+