ffi 1.2.0 → 1.2.1
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/Rakefile +3 -1
- data/ext/ffi_c/Type.c +1 -1
- data/ext/ffi_c/ffi.c +1 -1
- data/ffi.gemspec +18 -0
- data/lib/Lib.iml +9 -0
- data/spec/ffi/struct_spec.rb +8 -8
- metadata +59 -74
- data/ext/ffi_c/LongDouble.c.orig +0 -65
data/Rakefile
CHANGED
@@ -72,7 +72,9 @@ LIBTEST = "build/libtest.#{LIBEXT}"
|
|
72
72
|
BUILD_DIR = "build"
|
73
73
|
BUILD_EXT_DIR = File.join(BUILD_DIR, "#{RbConfig::CONFIG['arch']}", 'ffi_c', RUBY_VERSION)
|
74
74
|
|
75
|
-
gem_spec
|
75
|
+
def gem_spec
|
76
|
+
@gem_spec ||= Gem::Specification.load('ffi.gemspec')
|
77
|
+
end
|
76
78
|
|
77
79
|
Gem::PackageTask.new(gem_spec) do |pkg|
|
78
80
|
pkg.need_zip = true
|
data/ext/ffi_c/Type.c
CHANGED
@@ -39,6 +39,7 @@ static void builtin_type_free(BuiltinType *);
|
|
39
39
|
VALUE rbffi_TypeClass = Qnil;
|
40
40
|
|
41
41
|
static VALUE classBuiltinType = Qnil;
|
42
|
+
static VALUE moduleNativeType = Qnil;
|
42
43
|
static VALUE typeMap = Qnil, sizeMap = Qnil;
|
43
44
|
static ID id_find_type = 0, id_type_size = 0, id_size = 0;
|
44
45
|
|
@@ -243,7 +244,6 @@ rbffi_Type_Find(VALUE name)
|
|
243
244
|
void
|
244
245
|
rbffi_Type_Init(VALUE moduleFFI)
|
245
246
|
{
|
246
|
-
VALUE moduleNativeType;
|
247
247
|
/*
|
248
248
|
* Document-class: FFI::Type
|
249
249
|
* This class manages C types.
|
data/ext/ffi_c/ffi.c
CHANGED
@@ -56,7 +56,7 @@ Init_ffi_c(void) {
|
|
56
56
|
* This module embbed type constants from {FFI::NativeType}.
|
57
57
|
*/
|
58
58
|
rbffi_FFIModule = moduleFFI = rb_define_module("FFI");
|
59
|
-
rb_global_variable(&
|
59
|
+
rb_global_variable(&rbffi_FFIModule);
|
60
60
|
|
61
61
|
|
62
62
|
/* FFI::Type needs to be initialized before most other classes */
|
data/ffi.gemspec
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'ffi'
|
3
|
+
s.version = '1.2.1'
|
4
|
+
s.author = 'Wayne Meissner'
|
5
|
+
s.email = 'wmeissner@gmail.com'
|
6
|
+
s.homepage = 'http://wiki.github.com/ffi/ffi'
|
7
|
+
s.summary = 'Ruby FFI'
|
8
|
+
s.description = 'Ruby FFI library'
|
9
|
+
s.files = %w(ffi.gemspec History.txt LICENSE COPYING COPYING.LESSER README.md Rakefile) + Dir.glob("{ext,gen,lib,spec,libtest}/**/*").reject { |f| f =~ /lib\/1\.[89]/}
|
10
|
+
s.extensions << 'ext/ffi_c/extconf.rb'
|
11
|
+
s.has_rdoc = false
|
12
|
+
s.license = 'LGPL-3'
|
13
|
+
s.require_paths << 'ext/ffi_c'
|
14
|
+
s.required_ruby_version = '>= 1.8.7'
|
15
|
+
s.add_development_dependency 'rake'
|
16
|
+
s.add_development_dependency 'rake-compiler', '>=0.6.0'
|
17
|
+
s.add_development_dependency 'rspec'
|
18
|
+
end
|
data/lib/Lib.iml
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="FacetManager">
|
4
|
+
<facet type="gem" name="Gem">
|
5
|
+
<configuration>
|
6
|
+
<option name="GEM_APP_ROOT_PATH" value="" />
|
7
|
+
<option name="GEM_APP_TEST_PATH" value="" />
|
8
|
+
<option name="GEM_APP_LIB_PATH" value="" />
|
9
|
+
</configuration>
|
10
|
+
</facet>
|
11
|
+
</component>
|
3
12
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
4
13
|
<exclude-output />
|
5
14
|
<content url="file://$MODULE_DIR$">
|
data/spec/ffi/struct_spec.rb
CHANGED
@@ -740,10 +740,10 @@ describe "variable-length arrays" do
|
|
740
740
|
layout :count, :int, :data, [ :long, 0 ]
|
741
741
|
end
|
742
742
|
s = struct_class.new(FFI::MemoryPointer.new(1024))
|
743
|
-
s[:data][0] =
|
744
|
-
s[:data][1] =
|
745
|
-
s[:data][0].should eq
|
746
|
-
s[:data][1].should eq
|
743
|
+
s[:data][0] = 0x1eadbeef
|
744
|
+
s[:data][1] = 0x12345678
|
745
|
+
s[:data][0].should eq 0x1eadbeef
|
746
|
+
s[:data][1].should eq 0x12345678
|
747
747
|
end
|
748
748
|
|
749
749
|
it "non-variable length array is bounds checked" do
|
@@ -751,9 +751,9 @@ describe "variable-length arrays" do
|
|
751
751
|
layout :count, :int, :data, [ :long, 1 ]
|
752
752
|
end
|
753
753
|
s = struct_class.new(FFI::MemoryPointer.new(1024))
|
754
|
-
s[:data][0] =
|
755
|
-
lambda { s[:data][1] =
|
756
|
-
s[:data][0].should eq
|
757
|
-
lambda { s[:data][1].should eq
|
754
|
+
s[:data][0] = 0x1eadbeef
|
755
|
+
lambda { s[:data][1] = 0x12345678 }.should raise_error
|
756
|
+
s[:data][0].should eq 0x1eadbeef
|
757
|
+
lambda { s[:data][1].should eq 0x12345678 }.should raise_error
|
758
758
|
end
|
759
759
|
end
|
metadata
CHANGED
@@ -1,75 +1,72 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.1
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 2
|
9
|
-
- 0
|
10
|
-
version: 1.2.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Wayne Meissner
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
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
|
23
17
|
none: false
|
24
|
-
requirements:
|
25
|
-
- -
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
segments:
|
29
|
-
- 0
|
30
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
31
22
|
type: :development
|
32
|
-
name: rake
|
33
|
-
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
23
|
prerelease: false
|
36
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
25
|
none: false
|
38
|
-
requirements:
|
39
|
-
- -
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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
|
46
37
|
version: 0.6.0
|
47
38
|
type: :development
|
48
|
-
name: rake-compiler
|
49
|
-
version_requirements: *id002
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
39
|
prerelease: false
|
52
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
41
|
none: false
|
54
|
-
requirements:
|
55
|
-
- -
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
|
58
|
-
|
59
|
-
- 0
|
60
|
-
version: "0"
|
61
|
-
type: :development
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.6.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
62
47
|
name: rspec
|
63
|
-
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
64
62
|
description: Ruby FFI library
|
65
63
|
email: wmeissner@gmail.com
|
66
64
|
executables: []
|
67
|
-
|
68
|
-
extensions:
|
65
|
+
extensions:
|
69
66
|
- ext/ffi_c/extconf.rb
|
70
67
|
extra_rdoc_files: []
|
71
|
-
|
72
|
-
|
68
|
+
files:
|
69
|
+
- ffi.gemspec
|
73
70
|
- History.txt
|
74
71
|
- LICENSE
|
75
72
|
- COPYING
|
@@ -375,7 +372,6 @@ files:
|
|
375
372
|
- ext/ffi_c/libffi.vc.mk
|
376
373
|
- ext/ffi_c/libffi.vc64.mk
|
377
374
|
- ext/ffi_c/LongDouble.c
|
378
|
-
- ext/ffi_c/LongDouble.c.orig
|
379
375
|
- ext/ffi_c/LongDouble.h
|
380
376
|
- ext/ffi_c/MappedType.c
|
381
377
|
- ext/ffi_c/MappedType.h
|
@@ -505,40 +501,29 @@ files:
|
|
505
501
|
- libtest/UnionTest.c
|
506
502
|
- libtest/VariadicTest.c
|
507
503
|
homepage: http://wiki.github.com/ffi/ffi
|
508
|
-
licenses:
|
504
|
+
licenses:
|
509
505
|
- LGPL-3
|
510
506
|
post_install_message:
|
511
507
|
rdoc_options: []
|
512
|
-
|
513
|
-
require_paths:
|
508
|
+
require_paths:
|
514
509
|
- lib
|
515
510
|
- ext/ffi_c
|
516
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
511
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
517
512
|
none: false
|
518
|
-
requirements:
|
519
|
-
- -
|
520
|
-
- !ruby/object:Gem::Version
|
521
|
-
hash: 57
|
522
|
-
segments:
|
523
|
-
- 1
|
524
|
-
- 8
|
525
|
-
- 7
|
513
|
+
requirements:
|
514
|
+
- - ! '>='
|
515
|
+
- !ruby/object:Gem::Version
|
526
516
|
version: 1.8.7
|
527
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
517
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
528
518
|
none: false
|
529
|
-
requirements:
|
530
|
-
- -
|
531
|
-
- !ruby/object:Gem::Version
|
532
|
-
|
533
|
-
segments:
|
534
|
-
- 0
|
535
|
-
version: "0"
|
519
|
+
requirements:
|
520
|
+
- - ! '>='
|
521
|
+
- !ruby/object:Gem::Version
|
522
|
+
version: '0'
|
536
523
|
requirements: []
|
537
|
-
|
538
524
|
rubyforge_project:
|
539
525
|
rubygems_version: 1.8.24
|
540
526
|
signing_key:
|
541
527
|
specification_version: 3
|
542
528
|
summary: Ruby FFI
|
543
529
|
test_files: []
|
544
|
-
|
data/ext/ffi_c/LongDouble.c.orig
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
#include "LongDouble.h"
|
2
|
-
#include <stdio.h>
|
3
|
-
#include <stdarg.h>
|
4
|
-
#include <float.h>
|
5
|
-
|
6
|
-
#if defined (__CYGWIN__) || defined(__INTERIX)
|
7
|
-
|
8
|
-
#define strtold(str, endptr) ((long double)strtod((str),(endptr)))
|
9
|
-
|
10
|
-
#endif /* defined (__CYGWIN__) */
|
11
|
-
|
12
|
-
static VALUE rb_cBigDecimal = Qnil;
|
13
|
-
static VALUE bigdecimal_load(VALUE unused);
|
14
|
-
static VALUE bigdecimal_failed(VALUE value);
|
15
|
-
|
16
|
-
VALUE
|
17
|
-
rbffi_longdouble_new(long double ld)
|
18
|
-
{
|
19
|
-
if (!RTEST(rb_cBigDecimal)) {
|
20
|
-
/* allow fallback if the bigdecimal library is unavailable in future ruby versions */
|
21
|
-
rb_cBigDecimal = rb_rescue(bigdecimal_load, Qnil, bigdecimal_failed, rb_cObject);
|
22
|
-
}
|
23
|
-
|
24
|
-
if (RTEST(rb_cBigDecimal) && rb_cBigDecimal != rb_cObject) {
|
25
|
-
char buf[128];
|
26
|
-
return rb_funcall(rb_cBigDecimal, rb_intern("new"), 1, rb_str_new(buf, sprintf(buf, "%.35Le", ld)));
|
27
|
-
}
|
28
|
-
|
29
|
-
/* Fall through to handling as a float */
|
30
|
-
return rb_float_new(ld);
|
31
|
-
}
|
32
|
-
|
33
|
-
long double
|
34
|
-
rbffi_num2longdouble(VALUE value)
|
35
|
-
{
|
36
|
-
if (TYPE(value) == T_FLOAT) {
|
37
|
-
return rb_num2dbl(value);
|
38
|
-
}
|
39
|
-
|
40
|
-
if (!RTEST(rb_cBigDecimal) && rb_const_defined(rb_cObject, rb_intern("BigDecimal"))) {
|
41
|
-
rb_cBigDecimal = rb_const_get(rb_cObject, rb_intern("BigDecimal"));
|
42
|
-
}
|
43
|
-
|
44
|
-
if (RTEST(rb_cBigDecimal) && rb_cBigDecimal != rb_cObject && RTEST(rb_obj_is_kind_of(value, rb_cBigDecimal))) {
|
45
|
-
VALUE s = rb_funcall(value, rb_intern("to_s"), 1, rb_str_new2("E"));
|
46
|
-
return strtold(RSTRING_PTR(s), NULL);
|
47
|
-
}
|
48
|
-
|
49
|
-
/* Fall through to handling as a float */
|
50
|
-
return rb_num2dbl(value);
|
51
|
-
}
|
52
|
-
|
53
|
-
|
54
|
-
static VALUE
|
55
|
-
bigdecimal_load(VALUE unused)
|
56
|
-
{
|
57
|
-
rb_require("bigdecimal");
|
58
|
-
return rb_const_get(rb_cObject, rb_intern("BigDecimal"));
|
59
|
-
}
|
60
|
-
|
61
|
-
static VALUE
|
62
|
-
bigdecimal_failed(VALUE value)
|
63
|
-
{
|
64
|
-
return value;
|
65
|
-
}
|