gir_ffi 0.9.3 → 0.9.4

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: 32348b4646865dc62bc64b2138a2e2103a6e1260
4
- data.tar.gz: d62d4d20fd485c6c67e245850e76838b2efd1065
3
+ metadata.gz: 45d1fd64a20d066116552af625c33d0173bd6c47
4
+ data.tar.gz: 404f1c8c32d94fff866f0e3499a62f4b9727ebc8
5
5
  SHA512:
6
- metadata.gz: 75e7375073038d8189f15cc7b1c30209beedde82144f6eb50fbb794be81b3be2689de49f5b3db9322a875c81bfdda22f8a4260cadb4f59e9b0c957e19bb16582
7
- data.tar.gz: a932d8198cc5fbed0418e658fda7b4031ae3373642228139c6b1645557e8e4192d706b6fe0f5c21ac5e65d29558a1b1e35a7032b2eec033f479d7d508d558806
6
+ metadata.gz: 99533353d82d5700a0ecf734c4829157a51923b00b7bd40201dd760a8d6800865e6d00778182826565ac1ccf2bde68736d33cbb70116542ecf7d72e24a7d383e
7
+ data.tar.gz: d9ddd4fe6a2017148a447d4ac8a9573905cd76cd73dabc7248f60fd75417f530751cf731286f5600e8c70baf89b97db73ff9847ef77505cf669f8231a63b8e75
data/Changelog.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.4 / 2016-02-22
4
+
5
+ * Pass nil user data as null pointer, and store a missing callback as nil. This
6
+ avoids passing a null callback and a non-null user data value, which causes
7
+ problems with vte_terminal_spawn_sync() and perhaps other functions.
8
+
3
9
  ## 0.9.3 / 2016-02-20
4
10
 
5
11
  * Make allow-none arguments optional in Ruby
@@ -10,7 +10,7 @@ module GirFFI
10
10
  end
11
11
 
12
12
  def conversion
13
- "GirFFI::InPointer.from_closure_data(#{callback_argument_name}.object_id)"
13
+ "GirFFI::InPointer.from_closure_data(#{callback_argument_name})"
14
14
  end
15
15
 
16
16
  private
@@ -38,8 +38,8 @@ module GirFFI
38
38
  CALLBACKS[prc.object_id] = prc
39
39
  end
40
40
 
41
- def self.drop_callback(key)
42
- CALLBACKS.delete key
41
+ def self.drop_callback(prc)
42
+ CALLBACKS.delete prc.object_id
43
43
  end
44
44
 
45
45
  # Create Callback from a Proc. Makes sure arguments are properly wrapped,
@@ -8,6 +8,7 @@ module GirFFI
8
8
  end
9
9
 
10
10
  def store(obj)
11
+ return FFI::Pointer::NULL if obj.nil?
11
12
  # FIXME: Don't use object_id!
12
13
  key = obj.object_id
13
14
  @store[key] = obj
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  # Current GirFFI version
3
3
  module GirFFI
4
- VERSION = '0.9.3'.freeze
4
+ VERSION = '0.9.4'.freeze
5
5
  end
data/tasks/test.rake CHANGED
@@ -201,3 +201,4 @@ file "test/lib/configure" => ["test/lib/autogen.sh", "test/lib/configure.ac"] do
201
201
  end
202
202
 
203
203
  task test: 'test:all'
204
+ task test: 'test:features'
@@ -6,7 +6,7 @@ describe GLib::DestroyNotify do
6
6
  it 'removes the passed-in key from the callback store' do
7
7
  dummy_proc = 'some-callback'
8
8
  GirFFI::CallbackBase.store_callback dummy_proc
9
- user_data = GirFFI::InPointer.from_closure_data dummy_proc.object_id
9
+ user_data = GirFFI::InPointer.from_closure_data dummy_proc
10
10
  GLib::DestroyNotify.default.call user_data
11
11
  GirFFI::CallbackBase::CALLBACKS[dummy_proc.object_id].must_be_nil
12
12
  end
@@ -68,7 +68,7 @@ describe GirFFI::Builders::ArgumentBuilder do
68
68
  end
69
69
 
70
70
  it 'has the correct value for #pre_conversion' do
71
- builder.pre_conversion.must_equal ['_v1 = GirFFI::InPointer.from_closure_data(foo.object_id)']
71
+ builder.pre_conversion.must_equal ['_v1 = GirFFI::InPointer.from_closure_data(foo)']
72
72
  end
73
73
 
74
74
  it 'has the correct value for #post_conversion' do
@@ -42,7 +42,7 @@ describe GirFFI::Builders::FunctionBuilder do
42
42
  code.must_equal <<-CODE.reset_indentation
43
43
  def self.test_callback_destroy_notify(&callback)
44
44
  _v1 = Regress::TestCallbackUserData.from(callback)
45
- _v2 = GirFFI::InPointer.from_closure_data(_v1.object_id)
45
+ _v2 = GirFFI::InPointer.from_closure_data(_v1)
46
46
  _v3 = GLib::DestroyNotify.default
47
47
  _v4 = Regress::Lib.regress_test_callback_destroy_notify _v1, _v2, _v3
48
48
  return _v4
@@ -14,7 +14,7 @@ describe GirFFI::CallbackBase do
14
14
  it 'removes the corresponding proc from CALLBACKS' do
15
15
  dummy_proc = 'some-callback'
16
16
  GirFFI::CallbackBase.store_callback dummy_proc
17
- GirFFI::CallbackBase.drop_callback dummy_proc.object_id
17
+ GirFFI::CallbackBase.drop_callback dummy_proc
18
18
  GirFFI::CallbackBase::CALLBACKS[dummy_proc.object_id].must_be_nil
19
19
  end
20
20
  end
@@ -184,8 +184,8 @@ describe GirFFI::InPointer do
184
184
 
185
185
  describe '.from_closure_data' do
186
186
  describe 'when called with nil' do
187
- it 'returns a pointer pointing to nil.object_id' do
188
- GirFFI::InPointer.from_closure_data(nil).address.must_equal nil.object_id
187
+ it 'returns a null pointer' do
188
+ GirFFI::InPointer.from_closure_data(nil).must_be :null?
189
189
  end
190
190
  end
191
191
 
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+ require 'gir_ffi_test_helper'
3
+
4
+ describe GirFFI::ObjectStore do
5
+ let(:store) { GirFFI::ObjectStore.new }
6
+
7
+ describe '#store' do
8
+ it 'returns a non-null pointer when storing objects' do
9
+ obj = Object.new
10
+ ptr = store.store obj
11
+ ptr.wont_be :null?
12
+ end
13
+
14
+ it 'returns a null pointer when storing nil' do
15
+ ptr = store.store nil
16
+ ptr.must_be :null?
17
+ end
18
+ end
19
+
20
+ describe '#fetch' do
21
+ it 'returns the stored object when passed the key pointer' do
22
+ obj = Object.new
23
+ ptr = store.store obj
24
+ result = store.fetch ptr
25
+ result.must_equal obj
26
+ end
27
+
28
+ it 'returns the nil object when passed a null pointer' do
29
+ ptr = FFI::Pointer.new(0)
30
+ result = store.fetch ptr
31
+ result.must_be_nil
32
+ end
33
+
34
+ it 'returns the pointer itself when passed an unknown pointer' do
35
+ ptr = FFI::Pointer.new(42)
36
+ result = store.fetch ptr
37
+ result.must_equal ptr
38
+ end
39
+ end
40
+ end
@@ -2648,22 +2648,23 @@ describe Regress do
2648
2648
 
2649
2649
  it 'has a working function #test_callback_async' do
2650
2650
  a = 1
2651
- stored_id = nil
2652
- Regress.test_callback_async { |user_data| stored_id = user_data; a = 2 }
2651
+ stored_proc = nil
2652
+ Regress.test_callback_async { |user_data| stored_proc = user_data; a = 2 }
2653
2653
  result = Regress.test_callback_thaw_async
2654
2654
  a.must_equal 2
2655
- stored_id.wont_be_nil
2655
+ stored_proc.wont_be_nil
2656
2656
  result.must_equal 2
2657
2657
  # TODO: See when we can clean up the stored callback for async callbacks.
2658
- GirFFI::CallbackBase::CALLBACKS[stored_id].wont_be_nil
2658
+ GirFFI::CallbackBase::CALLBACKS[stored_proc.object_id].must_equal stored_proc
2659
2659
  end
2660
2660
 
2661
2661
  it 'has a working function #test_callback_destroy_notify' do
2662
2662
  a = 1
2663
- stored_id = nil
2664
- r1 = Regress.test_callback_destroy_notify { |user_data| stored_id = user_data; a = 2 }
2663
+ stored_proc = nil
2664
+ r1 = Regress.test_callback_destroy_notify { |user_data| stored_proc = user_data; a = 2 }
2665
2665
  a.must_equal 2
2666
- GirFFI::CallbackBase::CALLBACKS[stored_id].wont_be_nil
2666
+ stored_id = stored_proc.object_id
2667
+ GirFFI::CallbackBase::CALLBACKS[stored_id].must_equal stored_proc
2667
2668
 
2668
2669
  a = 3
2669
2670
  r2 = Regress.test_callback_thaw_notifications
metadata CHANGED
@@ -1,127 +1,127 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gir_ffi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
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-02-20 00:00:00.000000000 Z
11
+ date: 2016-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- type: :runtime
15
14
  name: ffi
16
15
  requirement: !ruby/object:Gem::Requirement
17
16
  requirements:
18
17
  - - "~>"
19
18
  - !ruby/object:Gem::Version
20
19
  version: '1.8'
20
+ type: :runtime
21
+ prerelease: false
21
22
  version_requirements: !ruby/object:Gem::Requirement
22
23
  requirements:
23
24
  - - "~>"
24
25
  - !ruby/object:Gem::Version
25
26
  version: '1.8'
26
- prerelease: false
27
27
  - !ruby/object:Gem::Dependency
28
- type: :runtime
29
28
  name: ffi-bit_masks
30
29
  requirement: !ruby/object:Gem::Requirement
31
30
  requirements:
32
31
  - - "~>"
33
32
  - !ruby/object:Gem::Version
34
33
  version: 0.1.0
34
+ type: :runtime
35
+ prerelease: false
35
36
  version_requirements: !ruby/object:Gem::Requirement
36
37
  requirements:
37
38
  - - "~>"
38
39
  - !ruby/object:Gem::Version
39
40
  version: 0.1.0
40
- prerelease: false
41
41
  - !ruby/object:Gem::Dependency
42
- type: :runtime
43
42
  name: indentation
44
43
  requirement: !ruby/object:Gem::Requirement
45
44
  requirements:
46
45
  - - "~>"
47
46
  - !ruby/object:Gem::Version
48
47
  version: 0.1.1
48
+ type: :runtime
49
+ prerelease: false
49
50
  version_requirements: !ruby/object:Gem::Requirement
50
51
  requirements:
51
52
  - - "~>"
52
53
  - !ruby/object:Gem::Version
53
54
  version: 0.1.1
54
- prerelease: false
55
55
  - !ruby/object:Gem::Dependency
56
- type: :development
57
56
  name: minitest
58
57
  requirement: !ruby/object:Gem::Requirement
59
58
  requirements:
60
59
  - - "~>"
61
60
  - !ruby/object:Gem::Version
62
61
  version: '5.5'
62
+ type: :development
63
+ prerelease: false
63
64
  version_requirements: !ruby/object:Gem::Requirement
64
65
  requirements:
65
66
  - - "~>"
66
67
  - !ruby/object:Gem::Version
67
68
  version: '5.5'
68
- prerelease: false
69
69
  - !ruby/object:Gem::Dependency
70
- type: :development
71
70
  name: minitest-rspec_mocks
72
71
  requirement: !ruby/object:Gem::Requirement
73
72
  requirements:
74
73
  - - "~>"
75
74
  - !ruby/object:Gem::Version
76
75
  version: 0.3.0
76
+ type: :development
77
+ prerelease: false
77
78
  version_requirements: !ruby/object:Gem::Requirement
78
79
  requirements:
79
80
  - - "~>"
80
81
  - !ruby/object:Gem::Version
81
82
  version: 0.3.0
82
- prerelease: false
83
83
  - !ruby/object:Gem::Dependency
84
- type: :development
85
84
  name: rspec-mocks
86
85
  requirement: !ruby/object:Gem::Requirement
87
86
  requirements:
88
87
  - - "~>"
89
88
  - !ruby/object:Gem::Version
90
89
  version: 3.4.1
90
+ type: :development
91
+ prerelease: false
91
92
  version_requirements: !ruby/object:Gem::Requirement
92
93
  requirements:
93
94
  - - "~>"
94
95
  - !ruby/object:Gem::Version
95
96
  version: 3.4.1
96
- prerelease: false
97
97
  - !ruby/object:Gem::Dependency
98
- type: :development
99
98
  name: rake
100
99
  requirement: !ruby/object:Gem::Requirement
101
100
  requirements:
102
101
  - - "~>"
103
102
  - !ruby/object:Gem::Version
104
103
  version: '10.1'
104
+ type: :development
105
+ prerelease: false
105
106
  version_requirements: !ruby/object:Gem::Requirement
106
107
  requirements:
107
108
  - - "~>"
108
109
  - !ruby/object:Gem::Version
109
110
  version: '10.1'
110
- prerelease: false
111
111
  - !ruby/object:Gem::Dependency
112
- type: :development
113
112
  name: aruba
114
113
  requirement: !ruby/object:Gem::Requirement
115
114
  requirements:
116
115
  - - "~>"
117
116
  - !ruby/object:Gem::Version
118
117
  version: 0.12.0
118
+ type: :development
119
+ prerelease: false
119
120
  version_requirements: !ruby/object:Gem::Requirement
120
121
  requirements:
121
122
  - - "~>"
122
123
  - !ruby/object:Gem::Version
123
124
  version: 0.12.0
124
- prerelease: false
125
125
  description: |2
126
126
  GirFFI creates bindings for GObject-based libraries at runtime based on introspection
127
127
  data provided by the GObject Introspection Repository (GIR) system. Bindings are created
@@ -391,6 +391,7 @@ files:
391
391
  - test/gir_ffi/interface_base_test.rb
392
392
  - test/gir_ffi/method_stubber_test.rb
393
393
  - test/gir_ffi/object_base_test.rb
394
+ - test/gir_ffi/object_store_test.rb
394
395
  - test/gir_ffi/sized_array_test.rb
395
396
  - test/gir_ffi/type_map_test.rb
396
397
  - test/gir_ffi/unintrospectable_type_info_test.rb