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.

@@ -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
+
@@ -224,4 +224,8 @@ describe "All enums" do
224
224
  enum[42424241].should eq nil
225
225
  enum[42424243].should eq nil
226
226
  end
227
+
228
+ it "duplicate enum keys rejected" do
229
+ lambda { enum [ :a, 0xfee1dead, :b, 0xdeadbeef, :a, 0 ] }.should raise_error
230
+ end
227
231
  end
@@ -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: 3102836071
4
+ hash: -1049754034
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
9
  - 0
10
10
  - pre
11
- - 1
12
- version: 1.2.0.pre1
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-09-15 00:00:00 +10:00
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:
Binary file