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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 35f0c0d049d4d368c306162a75fbc3e2f5d15f7a
4
- data.tar.gz: 2bc5789912987309b031c94477290b4988e26f4d
3
+ metadata.gz: 464fd086b86382dddea95e18946be4af246c36b4
4
+ data.tar.gz: c9c13a75efe36d9a513c7ff8d9327b1aab20e8cb
5
5
  SHA512:
6
- metadata.gz: cfe43dd9795cc18eb70b096306a7bb7413d581b7df91fbcbe0339788a379f73c4357b5d997db6064fd907563ae23f8943df3cf2b16153de10e3d7f0761f51427
7
- data.tar.gz: 667648adf9dc0ccfb8371af90fce175c4d28d3c450f2500a7b7715a05c07431d878a508ff4362a77307697554cabccb9f9051462ac840e9b8c8b91c57c633fe1
6
+ metadata.gz: d3324bd949d9d9915d1656641d9ab19831aa884adfbd36df8690749450405f9b75721bac8104c8ec4c75baf2ceb079219338abd61b2c43bab5d731382190394f
7
+ data.tar.gz: dffc23519a16b729b03372502594cb959733bd9c94305814829579cf99821e2d301173fd7cda51b82d0472136c33f78b0569f684f91701a20f34a37f7c85f298
data/Changelog.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.0 / 2016-03-23
4
+
5
+ * Ensure ownership of created RubyClosure objects
6
+
3
7
  ## 0.10.0.pre1 / 2016-03-22
4
8
 
5
9
  * Rework generated method code to use less indirection.
@@ -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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  # Current GirFFI version
3
3
  module GirFFI
4
- VERSION = '0.10.0.pre1'.freeze
4
+ VERSION = '0.10.0'.freeze
5
5
  end
@@ -2,26 +2,35 @@
2
2
  require 'gir_ffi_test_helper'
3
3
 
4
4
  describe GObject::RubyClosure do
5
- it 'has a constructor with a mandatory block argument' do
6
- assert_raises ArgumentError do
7
- GObject::RubyClosure.new
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
- it 'is a kind of Closure' do
12
- c = GObject::RubyClosure.new {}
13
- assert_kind_of GObject::Closure, c
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
- it 'is able to retrieve its block from its struct' do
17
- a = 0
18
- c = GObject::RubyClosure.new { a = 2 }
19
- c2 = GObject::RubyClosure.wrap(c.to_ptr)
20
- c2.invoke_block
21
- assert_equal 2, a
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 'its #marshaller singleton method' do
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
- it 'has GObject::Closure#invoke call its block' do
49
- a = 0
50
- c = GObject::RubyClosure.new { a = 2 }
51
- c2 = GObject::Closure.wrap(c.to_ptr)
52
- c2.invoke nil, nil, nil
53
- assert_equal 2, a
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.pre1
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-22 00:00:00.000000000 Z
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: 1.3.1
454
+ version: '0'
455
455
  requirements: []
456
456
  rubyforge_project:
457
457
  rubygems_version: 2.5.1