gir_ffi 0.8.5 → 0.8.6

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: 33c7535a4e04bc9db6d60c9b92fd70d7b6d15942
4
- data.tar.gz: f2a04471af13eda5efbd038f1f7fa80cb1b0458c
3
+ metadata.gz: fffb54bf2eca76e21e43bb5838e0f307063c2b6d
4
+ data.tar.gz: 4ab64e4d22d1deba88e930a3a7b046a19558b6aa
5
5
  SHA512:
6
- metadata.gz: f4542926a9b0514a68855b00991381fbeb40393001c8da662d2f711107b9276a1803a74910308338b2e7e7a73c32aff8c48d4fef96d10cbb8fe8619e80b09f95
7
- data.tar.gz: 9333b2763f9db28c70fee615905ce0e20d9eff912ac222fb136a1ed07cc1f8b4793dd27bbaa8814f44453e781528d7d3be5b25365fbb8dc846a2533dc1114d08
6
+ metadata.gz: 482f25f7934b20c3cb1768225f630081198b321e081c3ae74d70d6c7bd9f8ed45f10dc6c40bbca2d247d9637909e134e988b59811354f6f77f71cb392c45c60c
7
+ data.tar.gz: 8b0ed87c864d9af6f5b8c80f02bc457f0a0858a3c00f53d48b8b22e0cfe5fae768ae730b7b00c939efad503581cf126fd5c4e75f51a18d5957846e3c8c9795d0
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.6 / 2015-12-09
4
+
5
+ * Change handling of initializers in subclasses
6
+ * Subclasses with their own GType revert to the default GObject constructor
7
+ * Subclasses cannot use their parent classes' non-default contructors
8
+ * Find signals in ancestor classes of unintrospectable types
9
+
3
10
  ## 0.8.5 / 2015-12-04
4
11
 
5
12
  * Improve GObject::Value
@@ -11,6 +11,9 @@ module GObject
11
11
 
12
12
  alias_method :initialize_without_automatic_gtype, :initialize
13
13
  alias_method :initialize, :initialize_with_automatic_gtype
14
+ alias_method :base_initialize, :initialize
15
+
16
+ private :base_initialize
14
17
 
15
18
  def store_pointer(ptr)
16
19
  super
@@ -31,7 +31,14 @@ module GirFFI
31
31
  end
32
32
 
33
33
  def preparation
34
- ['obj = allocate']
34
+ if @info.safe_name == 'new'
35
+ ['obj = allocate']
36
+ else
37
+ [
38
+ "raise NoMethodError unless self == #{@info.container.full_type_name}",
39
+ 'obj = allocate'
40
+ ]
41
+ end
35
42
  end
36
43
 
37
44
  def invocation
@@ -51,6 +51,7 @@ module GirFFI
51
51
  end
52
52
  setup_vfunc_invokers
53
53
  setup_interfaces
54
+ provide_initializer
54
55
  end
55
56
 
56
57
  # FIXME: Private method only used in subclass
@@ -108,6 +109,16 @@ module GirFFI
108
109
  "
109
110
  end
110
111
 
112
+ def provide_initializer
113
+ return if info.find_method 'new'
114
+
115
+ klass.class_eval "
116
+ def initialize(properties = {})
117
+ base_initialize(properties)
118
+ end
119
+ "
120
+ end
121
+
111
122
  def setup_interfaces
112
123
  interfaces.each do |iface|
113
124
  klass.send :include, iface
@@ -19,12 +19,6 @@ module GirFFI
19
19
  def setup_instance_method(_method)
20
20
  false
21
21
  end
22
-
23
- private
24
-
25
- def ancestor_infos
26
- info.interfaces
27
- end
28
22
  end
29
23
  end
30
24
  end
@@ -43,5 +43,9 @@ module GirFFI
43
43
  def fields
44
44
  []
45
45
  end
46
+
47
+ def find_signal(_any)
48
+ nil
49
+ end
46
50
  end
47
51
  end
@@ -1,4 +1,4 @@
1
1
  # Current GirFFI version
2
2
  module GirFFI
3
- VERSION = '0.8.5'
3
+ VERSION = '0.8.6'
4
4
  end
@@ -23,6 +23,7 @@ describe GirFFI::Builders::ConstructorBuilder do
23
23
  it 'builds a custom constructor' do
24
24
  code.must_equal <<-CODE.reset_indentation
25
25
  def self.new_from_file(*args)
26
+ raise NoMethodError unless self == Regress::TestObj
26
27
  obj = allocate
27
28
  obj.__send__ :initialize_from_file, *args
28
29
  obj
@@ -46,6 +46,11 @@ describe GirFFI::Builders::UnintrospectableBuilder do
46
46
  end
47
47
  assert_match(/^Signal/, msg)
48
48
  end
49
+
50
+ it 'finds signals in ancestor classes' do
51
+ signal = @bldr.find_signal 'notify'
52
+ signal.name.must_equal 'notify'
53
+ end
49
54
  end
50
55
  end
51
56
  end
@@ -111,5 +111,14 @@ describe GirFFI::Builders::UserDefinedBuilder do
111
111
  other_klass = other_builder.build_class
112
112
  other_klass.gtype.must_equal gtype
113
113
  end
114
+
115
+ it 'creates a class with a new GType' do
116
+ klass.gtype.wont_equal GIMarshallingTests::Object.gtype
117
+ end
118
+
119
+ it 'makes the registered class return objects with the correct GType' do
120
+ obj = klass.new
121
+ GObject.type_from_instance(obj).must_equal klass.gtype
122
+ end
114
123
  end
115
124
  end
@@ -108,4 +108,12 @@ describe GirFFI::UnintrospectableTypeInfo do
108
108
  info.safe_name.must_equal 'GSomeType'
109
109
  end
110
110
  end
111
+
112
+ describe '#find_signal' do
113
+ it 'indicates that no signals can be found' do
114
+ info = GirFFI::UnintrospectableTypeInfo.new(:some_type)
115
+ result = info.find_signal 'any'
116
+ result.must_be_nil
117
+ end
118
+ end
111
119
  end
@@ -1206,11 +1206,13 @@ describe GIMarshallingTests do
1206
1206
 
1207
1207
  describe 'GIMarshallingTests::SubObject' do
1208
1208
  it 'creates an instance using #new' do
1209
- so = GIMarshallingTests::SubObject.new 42
1210
- assert_instance_of GIMarshallingTests::SubObject, so
1209
+ so = GIMarshallingTests::SubObject.new
1210
+ so.must_be_instance_of GIMarshallingTests::SubObject
1211
+ GObject.type_name(GObject.type_from_instance so).
1212
+ must_equal 'GIMarshallingTestsSubObject'
1211
1213
  end
1212
1214
 
1213
- let(:instance) { GIMarshallingTests::SubObject.new 0 }
1215
+ let(:instance) { GIMarshallingTests::SubObject.new }
1214
1216
 
1215
1217
  it 'has a working method #overwritten_method' do
1216
1218
  instance.overwritten_method
@@ -1230,11 +1232,13 @@ describe GIMarshallingTests do
1230
1232
 
1231
1233
  describe 'GIMarshallingTests::SubSubObject' do
1232
1234
  it 'creates an instance using #new' do
1233
- so = GIMarshallingTests::SubSubObject.new 42
1235
+ so = GIMarshallingTests::SubSubObject.new
1234
1236
  assert_instance_of GIMarshallingTests::SubSubObject, so
1237
+ GObject.type_name(GObject.type_from_instance so).
1238
+ must_equal 'GIMarshallingTestsSubSubObject'
1235
1239
  end
1236
1240
 
1237
- let(:instance) { GIMarshallingTests::SubSubObject.new 0 }
1241
+ let(:instance) { GIMarshallingTests::SubSubObject.new }
1238
1242
 
1239
1243
  it 'does not have field accessors' do
1240
1244
  assert_raises(NoMethodError) { instance.parent_instance }
@@ -2230,6 +2230,10 @@ describe Regress do
2230
2230
  assert_instance_of Regress::TestSubObj, tso
2231
2231
  end
2232
2232
 
2233
+ it "does not create an instance using its parent object's custom constructors" do
2234
+ proc { Regress::TestSubObj.constructor }.must_raise NoMethodError
2235
+ end
2236
+
2233
2237
  let(:instance) { Regress::TestSubObj.new }
2234
2238
 
2235
2239
  it 'has a working method #instance_method' 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.8.5
4
+ version: 0.8.6
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: 2015-12-04 00:00:00.000000000 Z
11
+ date: 2015-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -387,7 +387,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
387
387
  version: '0'
388
388
  requirements: []
389
389
  rubyforge_project:
390
- rubygems_version: 2.4.5.1
390
+ rubygems_version: 2.5.0
391
391
  signing_key:
392
392
  specification_version: 4
393
393
  summary: FFI-based GObject binding using the GObject Introspection Repository