ffi-extra 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/ffi/extra.rb +9 -7
  2. metadata +10 -5
@@ -78,7 +78,7 @@ module FFI
78
78
  end
79
79
 
80
80
  class Pointer
81
- def read (type)
81
+ def read (type, *args)
82
82
  if type.is_a?(Symbol)
83
83
  if respond_to? "read_#{type}"
84
84
  return send "read_#{type}"
@@ -88,17 +88,19 @@ module FFI
88
88
  end
89
89
 
90
90
  if type.is_a?(Type::Builtin)
91
- send "read_#{type.name.downcase}"
91
+ send "read_#{type.name.downcase}", *args
92
92
  elsif type.is_a?(Class) && type.ancestors.member?(FFI::Struct) && !type.ancestors.member?(FFI::ManagedStruct)
93
- type.new(self)
93
+ type.new(self, *args)
94
94
  elsif type.respond_to? :from_native
95
- type.from_native(typecast(type.native_type), nil)
95
+ type.from_native(typecast(type.native_type, *args), nil)
96
96
  else
97
97
  raise ArgumentError, 'you have to pass a Struct, a Builtin type or a Symbol'
98
98
  end
99
- end; alias typecast read
99
+ end
100
+
101
+ alias typecast read
100
102
 
101
- def write (what, type=nil)
103
+ def write (what, type = nil)
102
104
  if type
103
105
  if respond_to? "write_#{type.downcase}"
104
106
  send "write_#{type.downcase}", what
@@ -167,7 +169,7 @@ end
167
169
 
168
170
  [Numeric, String, NilClass, TrueClass, FalseClass, FFI::Pointer].each {|klass|
169
171
  klass.instance_eval {
170
- define_method :to_ffi do
172
+ define_method :to_native do
171
173
  self
172
174
  end
173
175
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-extra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-16 00:00:00.000000000 Z
12
+ date: 2012-06-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
16
- requirement: &5577320 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,12 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *5577320
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  description:
26
31
  email: meh@paranoici.org
27
32
  executables: []
@@ -50,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
55
  version: '0'
51
56
  requirements: []
52
57
  rubyforge_project:
53
- rubygems_version: 1.8.10
58
+ rubygems_version: 1.8.24
54
59
  signing_key:
55
60
  specification_version: 3
56
61
  summary: Some extra methods for FFI