ffi 1.2.0.pre1 → 1.2.0.pre2
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/COPYING +674 -0
- data/COPYING.LESSER +165 -0
- data/ext/ffi_c/LongDouble.c +4 -0
- data/ext/ffi_c/LongDouble.c.orig +65 -0
- data/ext/ffi_c/MethodHandle.c +1 -1
- data/ext/ffi_c/libffi.bsd.mk +1 -1
- data/ext/ffi_c/libffi.darwin.mk +6 -4
- data/ext/ffi_c/libffi.mk +1 -1
- data/lib/ffi/autopointer.rb +9 -8
- data/lib/ffi/enum.rb +2 -1
- data/libtest/Benchmark.c +66 -0
- data/libtest/BoolTest.c +45 -0
- data/libtest/BufferTest.c +45 -0
- data/libtest/ClosureTest.c +204 -0
- data/libtest/EnumTest.c +48 -0
- data/libtest/FunctionTest.c +72 -0
- data/libtest/GNUmakefile +149 -0
- data/libtest/GlobalVariable.c +76 -0
- data/libtest/LastErrorTest.c +35 -0
- data/libtest/NumberTest.c +146 -0
- data/libtest/PointerTest.c +77 -0
- data/libtest/ReferenceTest.c +37 -0
- data/libtest/StringTest.c +48 -0
- data/libtest/StructTest.c +254 -0
- data/libtest/UnionTest.c +57 -0
- data/libtest/VariadicTest.c +76 -0
- data/spec/ffi/enum_spec.rb +4 -0
- data/spec/ffi/pointer_spec.rb +17 -0
- metadata +23 -5
- data/lib/ffi_c.bundle +0 -0
data/libtest/UnionTest.c
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2007 Wayne Meissner. All rights reserved.
|
3
|
+
*
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* This file is part of ruby-ffi.
|
7
|
+
*
|
8
|
+
* This code is free software: you can redistribute it and/or modify it under
|
9
|
+
* the terms of the GNU Lesser General Public License version 3 only, as
|
10
|
+
* published by the Free Software Foundation.
|
11
|
+
*
|
12
|
+
* This code is distributed in the hope that it will be useful, but WITHOUT
|
13
|
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
14
|
+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
15
|
+
* version 3 for more details.
|
16
|
+
*
|
17
|
+
* You should have received a copy of the GNU Lesser General Public License
|
18
|
+
* version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
*/
|
20
|
+
|
21
|
+
#include <stdio.h>
|
22
|
+
#include <stdbool.h>
|
23
|
+
#include <stdint.h>
|
24
|
+
#include <string.h>
|
25
|
+
#include <stdlib.h>
|
26
|
+
|
27
|
+
typedef char s8;
|
28
|
+
typedef short s16;
|
29
|
+
typedef int s32;
|
30
|
+
typedef long long s64;
|
31
|
+
typedef float f32;
|
32
|
+
typedef double f64;
|
33
|
+
|
34
|
+
typedef union union_test {
|
35
|
+
char b;
|
36
|
+
short s;
|
37
|
+
int i;
|
38
|
+
long long j;
|
39
|
+
long l;
|
40
|
+
float f;
|
41
|
+
double d;
|
42
|
+
s8 a[10];
|
43
|
+
} union_test_t;
|
44
|
+
|
45
|
+
#define T(x, type) \
|
46
|
+
type union_align_##type(union_test_t* u) { return u->x; } \
|
47
|
+
union_test_t* union_make_union_with_##type(type value) { static union_test_t u; u.x = value; return &u; }
|
48
|
+
|
49
|
+
T(b, s8);
|
50
|
+
T(s, s16);
|
51
|
+
T(i, s32);
|
52
|
+
T(j, s64);
|
53
|
+
T(f, f32);
|
54
|
+
T(d, f64);
|
55
|
+
T(l, long);
|
56
|
+
|
57
|
+
unsigned int union_size() { return sizeof(union_test_t); }
|
@@ -0,0 +1,76 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2008 Wayne Meissner. All rights reserved.
|
3
|
+
*
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* This file is part of ruby-ffi.
|
7
|
+
*
|
8
|
+
* This code is free software: you can redistribute it and/or modify it under
|
9
|
+
* the terms of the GNU Lesser General Public License version 3 only, as
|
10
|
+
* published by the Free Software Foundation.
|
11
|
+
*
|
12
|
+
* This code is distributed in the hope that it will be useful, but WITHOUT
|
13
|
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
14
|
+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
15
|
+
* version 3 for more details.
|
16
|
+
*
|
17
|
+
* You should have received a copy of the GNU Lesser General Public License
|
18
|
+
* version 3 along with this work. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
*/
|
20
|
+
|
21
|
+
#include <sys/types.h>
|
22
|
+
#include <stdio.h>
|
23
|
+
#include <stdint.h>
|
24
|
+
#include <string.h>
|
25
|
+
#include <stdarg.h>
|
26
|
+
|
27
|
+
typedef int8_t s8;
|
28
|
+
typedef uint8_t u8;
|
29
|
+
typedef int16_t s16;
|
30
|
+
typedef uint16_t u16;
|
31
|
+
typedef int32_t s32;
|
32
|
+
typedef uint32_t u32;
|
33
|
+
typedef int64_t s64;
|
34
|
+
typedef uint64_t u64;
|
35
|
+
typedef signed long sL;
|
36
|
+
typedef unsigned long uL;
|
37
|
+
typedef float F;
|
38
|
+
typedef double D;
|
39
|
+
|
40
|
+
void pack_varargs(s64* buf, const char* fmt, ...)
|
41
|
+
{
|
42
|
+
va_list ap;
|
43
|
+
int c;
|
44
|
+
double d;
|
45
|
+
va_start(ap, fmt);
|
46
|
+
while ((c = *fmt++)) {
|
47
|
+
switch (c) {
|
48
|
+
case 'c':
|
49
|
+
case 's':
|
50
|
+
case 'i':
|
51
|
+
*buf++ = va_arg(ap, s32);
|
52
|
+
break;
|
53
|
+
case 'l':
|
54
|
+
*buf++ = va_arg(ap, long);
|
55
|
+
break;
|
56
|
+
case 'j':
|
57
|
+
*buf++ = va_arg(ap, s64);
|
58
|
+
break;
|
59
|
+
case 'f':
|
60
|
+
case 'd':
|
61
|
+
d = va_arg(ap, double);
|
62
|
+
memcpy(buf++, &d, sizeof(d));
|
63
|
+
break;
|
64
|
+
case 'C':
|
65
|
+
case 'S':
|
66
|
+
case 'I':
|
67
|
+
*buf++ = va_arg(ap, u32);
|
68
|
+
break;
|
69
|
+
case 'L':
|
70
|
+
*buf++ = va_arg(ap, unsigned long);
|
71
|
+
break;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
va_end(ap);
|
75
|
+
}
|
76
|
+
|
data/spec/ffi/enum_spec.rb
CHANGED
data/spec/ffi/pointer_spec.rb
CHANGED
@@ -210,5 +210,22 @@ describe "AutoPointer" do
|
|
210
210
|
end
|
211
211
|
|
212
212
|
end
|
213
|
+
|
214
|
+
describe "#autorelease?" do
|
215
|
+
ptr_class = Class.new(FFI::AutoPointer) do
|
216
|
+
def self.release(ptr); end
|
217
|
+
end
|
218
|
+
|
219
|
+
it "should be true by default" do
|
220
|
+
ptr_class.new(FFI::Pointer.new(0xdeadbeef)).autorelease?.should be_true
|
221
|
+
end
|
222
|
+
|
223
|
+
it "should return false when autorelease=(false)" do
|
224
|
+
ptr = ptr_class.new(FFI::Pointer.new(0xdeadbeef))
|
225
|
+
ptr.autorelease = false
|
226
|
+
ptr.autorelease?.should be_false
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
213
230
|
end
|
214
231
|
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: -1049754034
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
9
|
- 0
|
10
10
|
- pre
|
11
|
-
-
|
12
|
-
version: 1.2.0.
|
11
|
+
- 2
|
12
|
+
version: 1.2.0.pre2
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Wayne Meissner
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2012-
|
20
|
+
date: 2012-11-01 00:00:00 +11:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
@@ -75,6 +75,8 @@ extra_rdoc_files: []
|
|
75
75
|
files:
|
76
76
|
- History.txt
|
77
77
|
- LICENSE
|
78
|
+
- COPYING
|
79
|
+
- COPYING.LESSER
|
78
80
|
- README.md
|
79
81
|
- Rakefile
|
80
82
|
- ext/ffi_c/AbstractMemory.c
|
@@ -376,6 +378,7 @@ files:
|
|
376
378
|
- ext/ffi_c/libffi.vc.mk
|
377
379
|
- ext/ffi_c/libffi.vc64.mk
|
378
380
|
- ext/ffi_c/LongDouble.c
|
381
|
+
- ext/ffi_c/LongDouble.c.orig
|
379
382
|
- ext/ffi_c/LongDouble.h
|
380
383
|
- ext/ffi_c/MappedType.c
|
381
384
|
- ext/ffi_c/MappedType.h
|
@@ -455,7 +458,6 @@ files:
|
|
455
458
|
- lib/ffi/union.rb
|
456
459
|
- lib/ffi/variadic.rb
|
457
460
|
- lib/ffi.rb
|
458
|
-
- lib/ffi_c.bundle
|
459
461
|
- lib/Lib.iml
|
460
462
|
- spec/ffi/async_callback_spec.rb
|
461
463
|
- spec/ffi/bool_spec.rb
|
@@ -489,6 +491,22 @@ files:
|
|
489
491
|
- spec/ffi/union_spec.rb
|
490
492
|
- spec/ffi/variadic_spec.rb
|
491
493
|
- spec/spec.opts
|
494
|
+
- libtest/Benchmark.c
|
495
|
+
- libtest/BoolTest.c
|
496
|
+
- libtest/BufferTest.c
|
497
|
+
- libtest/ClosureTest.c
|
498
|
+
- libtest/EnumTest.c
|
499
|
+
- libtest/FunctionTest.c
|
500
|
+
- libtest/GlobalVariable.c
|
501
|
+
- libtest/GNUmakefile
|
502
|
+
- libtest/LastErrorTest.c
|
503
|
+
- libtest/NumberTest.c
|
504
|
+
- libtest/PointerTest.c
|
505
|
+
- libtest/ReferenceTest.c
|
506
|
+
- libtest/StringTest.c
|
507
|
+
- libtest/StructTest.c
|
508
|
+
- libtest/UnionTest.c
|
509
|
+
- libtest/VariadicTest.c
|
492
510
|
has_rdoc: true
|
493
511
|
homepage: http://wiki.github.com/ffi/ffi
|
494
512
|
licenses:
|
data/lib/ffi_c.bundle
DELETED
Binary file
|