gir_ffi 0.13.1 → 0.14.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
  SHA256:
3
- metadata.gz: 9c2f74f548641ffd8518e7be3b8de0be2d09543f6a7267e796084567972d6c72
4
- data.tar.gz: c1f84384a10427655b5907fc342c1690079acae27b076a118d743bb203b3f51c
3
+ metadata.gz: 2fc709e79ed9d8d423b39d2793e648a3d4cf62603496f5398fe80515a756fe96
4
+ data.tar.gz: 2ca46650022b545f0dff670fc8bbaa27c159ed43c101fde1d674ab064b4dec36
5
5
  SHA512:
6
- metadata.gz: e86e854c330672615eba303d0a34ce912d3766d74d7805a7e872dd5c7f0ddb13288ebb9be3b6293dbfc264d0c4d3013a0e2485aba3656511755e51f6bf5d1240
7
- data.tar.gz: 6722a19e4232c8ace606d2dc86fec59d5a8c4a3cdec88ea1bf86884897e514cade46b71b04cfc66ee19f901c36e08515288fa56becd6dbd720c5e51dccba8093
6
+ metadata.gz: ad913da79bffc07e693e94aa2e56aa0b425c48999b84ffcee0a92a06439b75a46cd7db04f19cb5bc87b8869c541b7b374538c9aea300c2ffbf973d50f8b8bc5c
7
+ data.tar.gz: d661d30631b2470b85f9ff59abf36e2c63f380ba94f40a5b98eb0e5fd1ebb0943b94c5b6dff2cb6737bc264746c014f5c24e080fceea13b7eb20a2de8077f54e
data/Changelog.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.14.0 / 2018-09-25
4
+
5
+ * Do not generate field accessors for Object types. Object data should normally
6
+ not be accessed directly.
7
+
3
8
  ## 0.13.1 / 2018-09-24
4
9
 
5
10
  * Silence some warnings.
@@ -5,6 +5,9 @@ GObject.load_class :ParamSpec
5
5
  module GObject
6
6
  # Overrides for GParamSpec, GObject's base class for parameter specifications.
7
7
  class ParamSpec
8
+ VALUE_TYPE_OFFSET = Struct.offset_of :value_type
9
+ FLAGS_OFFSET = Struct.offset_of :flags
10
+
8
11
  def ref
9
12
  Lib.g_param_spec_ref self
10
13
  self
@@ -13,5 +16,13 @@ module GObject
13
16
  def accessor_name
14
17
  get_name.tr('-', '_')
15
18
  end
19
+
20
+ def value_type
21
+ to_ptr.get_gtype(VALUE_TYPE_OFFSET)
22
+ end
23
+
24
+ def flags
25
+ GObject::ParamFlags.get_value_from_pointer(to_ptr, FLAGS_OFFSET)
26
+ end
16
27
  end
17
28
  end
@@ -39,15 +39,6 @@ module GirFFI
39
39
  @ancestor_infos ||= [info] + info.interfaces + parent_ancestor_infos
40
40
  end
41
41
 
42
- def eligible_fields
43
- info.fields.reject do |finfo|
44
- fname = finfo.name
45
- fname == 'parent_instance' ||
46
- info.find_instance_method("get_#{fname}") ||
47
- info.find_property(fname)
48
- end
49
- end
50
-
51
42
  def eligible_properties
52
43
  info.properties.reject do |pinfo|
53
44
  info.find_instance_method("get_#{pinfo.name}")
@@ -67,7 +58,6 @@ module GirFFI
67
58
  setup_layout
68
59
  setup_constants
69
60
  stub_methods
70
- setup_field_accessors
71
61
  setup_property_accessors
72
62
  setup_vfunc_invokers
73
63
  setup_interfaces
@@ -99,12 +89,6 @@ module GirFFI
99
89
  @parent_ancestor_infos ||= parent_builder.ancestor_infos
100
90
  end
101
91
 
102
- def setup_field_accessors
103
- eligible_fields.each do |finfo|
104
- FieldBuilder.new(finfo, klass).build
105
- end
106
- end
107
-
108
92
  def setup_property_accessors
109
93
  eligible_properties.each do |prop|
110
94
  PropertyBuilder.new(prop).build
@@ -76,7 +76,7 @@ module GirFFI
76
76
  end
77
77
 
78
78
  def interface_class
79
- @interface_class ||= Builder.build_by_gtype @param_spec.value_type if interface?
79
+ @interface_class ||= Builder.build_by_gtype(value_type) if interface?
80
80
  end
81
81
 
82
82
  def interface_class_name
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Current GirFFI version
4
4
  module GirFFI
5
- VERSION = '0.13.1'.freeze
5
+ VERSION = '0.14.0'.freeze
6
6
  end
@@ -63,9 +63,9 @@ describe GObject do
63
63
  10, 20, 15,
64
64
  3)
65
65
  spec.must_be_instance_of GObject::ParamSpecInt
66
- spec.minimum.must_equal 10
67
- spec.maximum.must_equal 20
68
- spec.default_value.must_equal 15
66
+ spec.struct[:minimum].must_equal 10
67
+ spec.struct[:maximum].must_equal 20
68
+ spec.get_default_value.must_equal 15
69
69
  end
70
70
  end
71
71
  end
@@ -124,7 +124,7 @@ describe GObject::Object do
124
124
  skip 'cannot be reliably tested on JRuby and Rubinius' if jruby? || rubinius?
125
125
 
126
126
  ptr = GObject::Object.new.to_ptr
127
- ref_count(ptr).must_equal 1
127
+ object_ref_count(ptr).must_equal 1
128
128
 
129
129
  GC.start
130
130
  # Creating a new object is sometimes needed to trigger enough garbage collection.
@@ -134,7 +134,7 @@ describe GObject::Object do
134
134
  GC.start
135
135
  GC.start
136
136
 
137
- ref_count(ptr).must_equal 0
137
+ object_ref_count(ptr).must_equal 0
138
138
  end
139
139
  end
140
140
  end
@@ -10,12 +10,13 @@ describe GObject::ParamSpec do
10
10
  1, 3, 2,
11
11
  readable: true, writable: true)
12
12
  end
13
+ let(:pspec_struct) { GObject::ParamSpec::Struct.new(pspec.to_ptr) }
13
14
 
14
15
  describe '#ref' do
15
16
  it 'increases the ref count' do
16
- old = pspec.ref_count
17
+ old = pspec_struct[:ref_count]
17
18
  pspec.ref
18
- pspec.ref_count.must_equal old + 1
19
+ pspec_struct[:ref_count].must_equal old + 1
19
20
  end
20
21
  end
21
22
 
@@ -70,9 +70,9 @@ describe GObject::Value do
70
70
  it 'wraps object values' do
71
71
  value = GObject::Object.new({})
72
72
  gv = GObject::Value.wrap_ruby_value value
73
- value.ref_count.must_equal 2
73
+ object_ref_count(value).must_equal 2
74
74
  gv.get_value.must_equal value
75
- value.ref_count.must_equal 3
75
+ object_ref_count(value).must_equal 3
76
76
  end
77
77
  end
78
78
 
@@ -79,23 +79,6 @@ describe GirFFI::Builders::ObjectBuilder do
79
79
  end
80
80
  end
81
81
 
82
- describe '#eligible_fields' do
83
- it 'skips fields that have a matching getter method' do
84
- result = param_spec_builder.eligible_fields
85
- result.map(&:name).wont_include 'name'
86
- end
87
-
88
- it 'skips fields that have a matching property' do
89
- result = obj_builder.eligible_fields
90
- result.map(&:name).wont_include 'hash_table'
91
- end
92
-
93
- it 'skips the parent instance field' do
94
- result = obj_builder.eligible_fields
95
- result.map(&:name).wont_include 'parent_instance'
96
- end
97
- end
98
-
99
82
  describe '#eligible_properties' do
100
83
  let(:wi_builder) do
101
84
  GirFFI::Builders::ObjectBuilder.new(
@@ -185,15 +185,16 @@ describe GirFFI::Builders::UserDefinedBuilder do
185
185
  obj = derived_class.new
186
186
  object = GIMarshallingTests::Object.new 42
187
187
  obj.object_prop = object
188
- object.ref_count.must_equal 2
188
+ object_ref_count(object).must_equal 2
189
189
  end
190
190
 
191
191
  it 'handles reference counting correctly when using the set_property method' do
192
192
  obj = derived_class.new
193
193
  object = GIMarshallingTests::Object.new 42
194
- object.ref_count.must_equal 1
194
+
195
+ object_ref_count(object).must_equal 1
195
196
  obj.set_property('object_prop', object)
196
- object.ref_count.must_equal 4 # Due to extra Value#set_value + Value#get_value
197
+ object_ref_count(object).must_equal 4 # Due to extra Value#set_value + Value#get_value
197
198
  end
198
199
  end
199
200
 
@@ -117,7 +117,7 @@ describe GirFFI::SizedArray do
117
117
  arr.to_ptr.wont_be :autorelease?
118
118
 
119
119
  arr.to_a.must_equal [obj, nil]
120
- obj.ref_count.must_equal 2
120
+ object_ref_count(obj).must_equal 2
121
121
  end
122
122
  end
123
123
 
@@ -31,8 +31,8 @@ module GirFFITestExtensions
31
31
  SAVED_MODULES.delete name
32
32
  end
33
33
 
34
- def ref_count(ptr)
35
- GObject::Object::Struct.new(ptr)[:ref_count]
34
+ def object_ref_count(ptr)
35
+ GObject::Object::Struct.new(ptr.to_ptr)[:ref_count]
36
36
  end
37
37
 
38
38
  def max_for_unsigned_type(type)
@@ -302,12 +302,12 @@ describe GIMarshallingTests do
302
302
 
303
303
  it 'has a working function #full_inout' do
304
304
  ob = GIMarshallingTests::Object.new 42
305
- ob.ref_count.must_equal 1
305
+ object_ref_count(ob).must_equal 1
306
306
 
307
307
  res = GIMarshallingTests::Object.full_inout ob
308
308
 
309
- ob.ref_count.must_equal 1
310
- res.ref_count.must_equal 1
309
+ object_ref_count(ob).must_equal 1
310
+ object_ref_count(res).must_equal 1
311
311
 
312
312
  res.must_be_instance_of GIMarshallingTests::Object
313
313
  res.int.must_equal 0
@@ -316,23 +316,23 @@ describe GIMarshallingTests do
316
316
  it 'has a working function #full_out' do
317
317
  res = GIMarshallingTests::Object.full_out
318
318
  res.must_be_instance_of GIMarshallingTests::Object
319
- res.ref_count.must_equal 1
319
+ object_ref_count(res).must_equal 1
320
320
  end
321
321
 
322
322
  it 'has a working function #full_return' do
323
323
  res = GIMarshallingTests::Object.full_return
324
324
  res.must_be_instance_of GIMarshallingTests::Object
325
- res.ref_count.must_equal 1
325
+ object_ref_count(res).must_equal 1
326
326
  end
327
327
 
328
328
  it 'has a working function #none_inout' do
329
329
  ob = GIMarshallingTests::Object.new 42
330
- ob.ref_count.must_equal 1
330
+ object_ref_count(ob).must_equal 1
331
331
 
332
332
  res = GIMarshallingTests::Object.none_inout ob
333
333
 
334
- ob.ref_count.must_equal 1
335
- res.ref_count.must_equal 2
334
+ object_ref_count(ob).must_equal 1
335
+ object_ref_count(res).must_equal 2
336
336
 
337
337
  res.must_be_instance_of GIMarshallingTests::Object
338
338
  ob.int.must_equal 42
@@ -342,13 +342,13 @@ describe GIMarshallingTests do
342
342
  it 'has a working function #none_out' do
343
343
  res = GIMarshallingTests::Object.none_out
344
344
  res.must_be_instance_of GIMarshallingTests::Object
345
- res.ref_count.must_equal 2
345
+ object_ref_count(res).must_equal 2
346
346
  end
347
347
 
348
348
  it 'has a working function #none_return' do
349
349
  res = GIMarshallingTests::Object.none_return
350
350
  res.must_be_instance_of GIMarshallingTests::Object
351
- res.ref_count.must_equal 2
351
+ object_ref_count(res).must_equal 2
352
352
  end
353
353
 
354
354
  it 'has a working function #static_method' do
@@ -411,7 +411,7 @@ describe GIMarshallingTests do
411
411
  end
412
412
  result = derived_instance.
413
413
  get_ref_info_for_vfunc_in_object_transfer_none GIMarshallingTests::Object.gtype
414
- obj.ref_count.must_be :>, 0
414
+ object_ref_count(obj).must_be :>, 0
415
415
  result.must_equal [2, false]
416
416
  obj.must_be_instance_of GIMarshallingTests::Object
417
417
  end
@@ -426,7 +426,7 @@ describe GIMarshallingTests do
426
426
  }
427
427
  end
428
428
  result = derived_instance.get_ref_info_for_vfunc_out_object_transfer_full
429
- obj.ref_count.must_be :>, 0
429
+ object_ref_count(obj).must_be :>, 0
430
430
  # TODO: Check desired result
431
431
  result.must_equal [2, false]
432
432
  end
@@ -752,11 +752,6 @@ describe GIMarshallingTests do
752
752
  instance.wont_respond_to :parent_instance
753
753
  instance.wont_respond_to :parent_instance=
754
754
  end
755
-
756
- it 'has a readable field long_' do
757
- instance.long_.must_equal 0
758
- instance.wont_respond_to :long_=
759
- end
760
755
  end
761
756
 
762
757
  describe 'GIMarshallingTests::OverridesStruct' do
@@ -1444,7 +1444,7 @@ describe Regress do
1444
1444
  end
1445
1445
 
1446
1446
  it 'has a reference count of 1' do
1447
- assert_equal 1, @o.ref_count
1447
+ assert_equal 1, object_ref_count(@o)
1448
1448
  end
1449
1449
 
1450
1450
  it 'has been sunk' do
@@ -1463,17 +1463,18 @@ describe Regress do
1463
1463
  end
1464
1464
 
1465
1465
  let(:derived_instance) { Regress::TestFundamentalSubObject.new 'foo' }
1466
+ let(:base_struct) { Regress::TestFundamentalObject::Struct.new derived_instance.to_ptr }
1466
1467
 
1467
1468
  it 'has a working method #ref' do
1468
- derived_instance.refcount.must_equal 1
1469
+ base_struct[:refcount].must_equal 1
1469
1470
  derived_instance.ref
1470
- derived_instance.refcount.must_equal 2
1471
+ base_struct[:refcount].must_equal 2
1471
1472
  end
1472
1473
 
1473
1474
  it 'has a working method #unref' do
1474
- derived_instance.refcount.must_equal 1
1475
+ base_struct[:refcount].must_equal 1
1475
1476
  derived_instance.unref
1476
- derived_instance.refcount.must_equal 0
1477
+ base_struct[:refcount].must_equal 0
1477
1478
  end
1478
1479
  end
1479
1480
 
@@ -1490,11 +1491,7 @@ describe Regress do
1490
1491
  end
1491
1492
 
1492
1493
  it 'has a field :data storing the constructor parameter' do
1493
- assert_equal 'foo', instance.data
1494
- end
1495
-
1496
- it "can access its parent class' fields directly" do
1497
- instance.flags.must_equal 0
1494
+ assert_equal 'foo', instance.struct[:data].to_utf8
1498
1495
  end
1499
1496
  end
1500
1497
 
@@ -1605,7 +1602,7 @@ describe Regress do
1605
1602
  end
1606
1603
 
1607
1604
  it 'has a reference count of 1' do
1608
- assert_equal 1, instance.ref_count
1605
+ assert_equal 1, object_ref_count(instance)
1609
1606
  end
1610
1607
 
1611
1608
  it 'does not float' do
@@ -1687,9 +1684,9 @@ describe Regress do
1687
1684
 
1688
1685
  it 'has a working method #instance_method_full' do
1689
1686
  skip unless get_method_introspection_data('Regress', 'TestObj', 'instance_method_full')
1690
- instance.ref_count.must_equal 1
1687
+ object_ref_count(instance).must_equal 1
1691
1688
  instance.instance_method_full
1692
- instance.ref_count.must_equal 1
1689
+ object_ref_count(instance).must_equal 1
1693
1690
  end
1694
1691
 
1695
1692
  it 'has a working method #not_nullable_element_typed_gpointer_in' do
@@ -3211,7 +3208,7 @@ describe Regress do
3211
3208
  skip unless get_introspection_data 'Regress', 'test_callback_return_full'
3212
3209
  obj = Regress::TestObj.constructor
3213
3210
  Regress.test_callback_return_full { obj }
3214
- obj.ref_count.must_equal 1
3211
+ object_ref_count(obj).must_equal 1
3215
3212
  end
3216
3213
 
3217
3214
  it 'has a working function #test_callback_thaw_async' do
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.13.1
4
+ version: 0.14.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: 2018-09-24 00:00:00.000000000 Z
11
+ date: 2018-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi