gir_ffi 0.10.0.pre1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +4 -0
- data/lib/ffi-gobject/closure.rb +7 -0
- data/lib/ffi-gobject.rb +3 -0
- data/lib/gir_ffi/version.rb +1 -1
- data/test/ffi-glib/ruby_closure_test.rb +31 -20
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 464fd086b86382dddea95e18946be4af246c36b4
|
4
|
+
data.tar.gz: c9c13a75efe36d9a513c7ff8d9327b1aab20e8cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3324bd949d9d9915d1656641d9ab19831aa884adfbd36df8690749450405f9b75721bac8104c8ec4c75baf2ceb079219338abd61b2c43bab5d731382190394f
|
7
|
+
data.tar.gz: dffc23519a16b729b03372502594cb959733bd9c94305814829579cf99821e2d301173fd7cda51b82d0472136c33f78b0569f684f91701a20f34a37f7c85f298
|
data/Changelog.md
CHANGED
data/lib/ffi-gobject/closure.rb
CHANGED
@@ -15,5 +15,12 @@ module GObject
|
|
15
15
|
callback = GObject::ClosureMarshal.from marshal
|
16
16
|
Lib.g_closure_set_marshal self, callback
|
17
17
|
end
|
18
|
+
|
19
|
+
def store_pointer(ptr)
|
20
|
+
super
|
21
|
+
# NOTE: Call C functions directly to avoid extra argument conversion
|
22
|
+
Lib.g_closure_ref ptr
|
23
|
+
Lib.g_closure_sink ptr
|
24
|
+
end
|
18
25
|
end
|
19
26
|
end
|
data/lib/ffi-gobject.rb
CHANGED
@@ -99,6 +99,9 @@ module GObject
|
|
99
99
|
attach_function :g_signal_connect_data,
|
100
100
|
[:pointer, :string, Callback, :pointer, ClosureNotify, ConnectFlags],
|
101
101
|
:ulong
|
102
|
+
|
103
|
+
attach_function :g_closure_ref, [:pointer], :pointer
|
104
|
+
attach_function :g_closure_sink, [:pointer], :pointer
|
102
105
|
attach_function :g_closure_set_marshal,
|
103
106
|
[:pointer, ClosureMarshal], :void
|
104
107
|
|
data/lib/gir_ffi/version.rb
CHANGED
@@ -2,26 +2,35 @@
|
|
2
2
|
require 'gir_ffi_test_helper'
|
3
3
|
|
4
4
|
describe GObject::RubyClosure do
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
describe '.new' do
|
6
|
+
it 'takes a mandatory block argument' do
|
7
|
+
assert_raises ArgumentError do
|
8
|
+
GObject::RubyClosure.new
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'returns a kind of Closure' do
|
13
|
+
c = GObject::RubyClosure.new {}
|
14
|
+
assert_kind_of GObject::Closure, c
|
8
15
|
end
|
9
|
-
end
|
10
16
|
|
11
|
-
|
12
|
-
|
13
|
-
|
17
|
+
it 'updates the ref_count of the created object' do
|
18
|
+
c = GObject::RubyClosure.new {}
|
19
|
+
c.ref_count.must_equal 1
|
20
|
+
end
|
14
21
|
end
|
15
22
|
|
16
|
-
|
17
|
-
a
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
23
|
+
describe '.wrap' do
|
24
|
+
it 'returns a fully functional object that can invoke the original block' do
|
25
|
+
a = 0
|
26
|
+
c = GObject::RubyClosure.new { a = 2 }
|
27
|
+
c2 = GObject::RubyClosure.wrap(c.to_ptr)
|
28
|
+
c2.invoke_block
|
29
|
+
assert_equal 2, a
|
30
|
+
end
|
22
31
|
end
|
23
32
|
|
24
|
-
describe '
|
33
|
+
describe '.marshaller' do
|
25
34
|
it "invokes its closure argument's block" do
|
26
35
|
a = 0
|
27
36
|
c = GObject::RubyClosure.new { a = 2 }
|
@@ -45,11 +54,13 @@ describe GObject::RubyClosure do
|
|
45
54
|
end
|
46
55
|
end
|
47
56
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
57
|
+
describe '#invoke' do
|
58
|
+
it 'invokes the ruby block' do
|
59
|
+
a = 0
|
60
|
+
c = GObject::RubyClosure.new { a = 2 }
|
61
|
+
c2 = GObject::Closure.wrap(c.to_ptr)
|
62
|
+
c2.invoke nil, nil, nil
|
63
|
+
assert_equal 2, a
|
64
|
+
end
|
54
65
|
end
|
55
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gir_ffi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.0
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matijs van Zuijlen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -449,9 +449,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
449
449
|
version: 2.0.0
|
450
450
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
451
451
|
requirements:
|
452
|
-
- - "
|
452
|
+
- - ">="
|
453
453
|
- !ruby/object:Gem::Version
|
454
|
-
version:
|
454
|
+
version: '0'
|
455
455
|
requirements: []
|
456
456
|
rubyforge_project:
|
457
457
|
rubygems_version: 2.5.1
|