ffi-inline 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/ffi/inliner/builders.rb +2 -2
- data/lib/ffi/inliner/builders/c.rb +1 -0
- data/lib/ffi/inliner/builders/cpp.rb +1 -0
- data/lib/ffi/inliner/version.rb +1 -1
- data/spec/inliner_spec.rb +21 -0
- metadata +9 -9
data/lib/ffi/inliner/builders.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module FFI; module Inliner
|
2
2
|
|
3
|
-
Signature = ::Struct.new(:return, :name, :arguments, :arity)
|
3
|
+
Signature = ::Struct.new(:return, :name, :arguments, :arity, :blocking)
|
4
4
|
|
5
5
|
class Builder
|
6
6
|
@builders = []
|
@@ -84,7 +84,7 @@ class Builder
|
|
84
84
|
builder.signatures.each {|s|
|
85
85
|
attach_function s.name, s.arguments.compact.map {|a|
|
86
86
|
builder.to_ffi_type(a, self)
|
87
|
-
}, builder.to_ffi_type(s.return, self)
|
87
|
+
}, builder.to_ffi_type(s.return, self), :blocking => s.blocking
|
88
88
|
}
|
89
89
|
}
|
90
90
|
|
@@ -63,6 +63,7 @@ Builder.define :c do
|
|
63
63
|
if signature
|
64
64
|
parsed[:arguments] = signature[:arguments] if signature[:arguments]
|
65
65
|
parsed[:return] = signature[:return] if signature[:return]
|
66
|
+
parsed[:blocking] = signature[:blocking] if signature[:blocking]
|
66
67
|
end
|
67
68
|
|
68
69
|
@signatures << parsed
|
@@ -16,6 +16,7 @@ Builder.define Builder[:c], :cplusplus, :cxx, :cpp, 'c++' do
|
|
16
16
|
if signature
|
17
17
|
parsed[:arguments] = signature[:arguments] if signature[:arguments]
|
18
18
|
parsed[:return] = signature[:return] if signature[:return]
|
19
|
+
parsed[:blocking] = signature[:blocking] if signature[:blocking]
|
19
20
|
end
|
20
21
|
|
21
22
|
@signatures << parsed
|
data/lib/ffi/inliner/version.rb
CHANGED
data/spec/inliner_spec.rb
CHANGED
@@ -232,6 +232,27 @@ EOC
|
|
232
232
|
}.should raise_error(/compile error/)
|
233
233
|
end
|
234
234
|
|
235
|
+
it 'should respect blocking flag' do
|
236
|
+
module Foo
|
237
|
+
inline do |builder|
|
238
|
+
builder.function %{
|
239
|
+
void blocking_function () {
|
240
|
+
#if defined(_WIN32)
|
241
|
+
Sleep(1000);
|
242
|
+
#else
|
243
|
+
sleep(1);
|
244
|
+
#endif
|
245
|
+
}
|
246
|
+
}, :blocking=>true
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
st = Time.now
|
251
|
+
Array.new(4){ Thread.new{ Foo.blocking_function } }.map(&:join)
|
252
|
+
|
253
|
+
(Time.now - st).should < 4
|
254
|
+
end
|
255
|
+
|
235
256
|
describe 'GXX compiler' do
|
236
257
|
it 'should compile and link a shim C library that encapsulates C++ code' do
|
237
258
|
module Foo
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-inline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
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: 2012-
|
12
|
+
date: 2012-03-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi
|
16
|
-
requirement: &
|
16
|
+
requirement: &13638240 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.4.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *13638240
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &13634060 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *13634060
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &13632840 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *13632840
|
47
47
|
description:
|
48
48
|
email: meh@paranoici.org
|
49
49
|
executables: []
|
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
85
|
version: '0'
|
86
86
|
requirements: []
|
87
87
|
rubyforge_project:
|
88
|
-
rubygems_version: 1.8.
|
88
|
+
rubygems_version: 1.8.11
|
89
89
|
signing_key:
|
90
90
|
specification_version: 3
|
91
91
|
summary: Inline C/C++ in Ruby easily and cleanly.
|