ffi 1.2.0.pre3 → 1.2.0.pre4
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.
- data/lib/ffi/library.rb +4 -2
- data/spec/ffi/callback_spec.rb +11 -1
- metadata +2 -2
data/lib/ffi/library.rb
CHANGED
@@ -212,7 +212,7 @@ module FFI
|
|
212
212
|
cname, arg_types, ret_type, opts = (a4 && (a2.is_a?(String) || a2.is_a?(Symbol))) ? [ a2, a3, a4, a5 ] : [ mname.to_s, a2, a3, a4 ]
|
213
213
|
|
214
214
|
# Convert :foo to the native type
|
215
|
-
arg_types.map
|
215
|
+
arg_types = arg_types.map { |e| find_type(e) }
|
216
216
|
options = {
|
217
217
|
:convention => ffi_convention,
|
218
218
|
:type_map => defined?(@ffi_typedefs) ? @ffi_typedefs : nil,
|
@@ -361,10 +361,12 @@ code
|
|
361
361
|
[ nil, args[0], args[1] ]
|
362
362
|
end
|
363
363
|
|
364
|
+
native_params = params.map { |e| find_type(e) }
|
365
|
+
raise ArgumentError, "callbacks cannot have variadic parameters" if native_params.include?(FFI::Type::VARARGS)
|
364
366
|
options = Hash.new
|
365
367
|
options[:convention] = ffi_convention
|
366
368
|
options[:enums] = @ffi_enums if defined?(@ffi_enums)
|
367
|
-
cb = FFI::CallbackInfo.new(find_type(ret),
|
369
|
+
cb = FFI::CallbackInfo.new(find_type(ret), native_params, options)
|
368
370
|
|
369
371
|
# Add to the symbol -> type map (unless there was no name)
|
370
372
|
unless name.nil?
|
data/spec/ffi/callback_spec.rb
CHANGED
@@ -665,4 +665,14 @@ describe "Callback with " do
|
|
665
665
|
v.pointer.should eq FFI::Pointer::NULL
|
666
666
|
end
|
667
667
|
|
668
|
-
|
668
|
+
it "varargs parameters are rejected" do
|
669
|
+
lambda {
|
670
|
+
Module.new do
|
671
|
+
extend FFI::Library
|
672
|
+
ffi_lib TestLibrary::PATH
|
673
|
+
callback :cbVrL, [ :varargs ], :long
|
674
|
+
end
|
675
|
+
}.should raise_error(ArgumentError)
|
676
|
+
end
|
677
|
+
|
678
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.0.
|
4
|
+
version: 1.2.0.pre4
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|