gir_ffi 0.15.2 → 0.15.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +11 -0
- data/Gemfile +1 -1
- data/lib/ffi-gobject/value.rb +3 -1
- data/lib/ffi-gobject_introspection/i_base_info.rb +1 -1
- data/lib/gir_ffi/builder_helper.rb +6 -1
- data/lib/gir_ffi/builders/callback_builder.rb +13 -1
- data/lib/gir_ffi/builders/enum_builder.rb +6 -2
- data/lib/gir_ffi/builders/field_builder.rb +2 -1
- data/lib/gir_ffi/builders/module_builder.rb +3 -1
- data/lib/gir_ffi/builders/struct_builder.rb +3 -1
- data/lib/gir_ffi/callback_base.rb +3 -5
- data/lib/gir_ffi/class_base.rb +1 -0
- data/lib/gir_ffi/version.rb +1 -1
- data/test/ffi-gobject/object_test.rb +3 -2
- data/test/ffi-gobject/value_test.rb +1 -1
- data/test/ffi-gobject_introspection/i_base_info_test.rb +1 -1
- data/test/ffi-gobject_test.rb +4 -2
- data/test/gir_ffi/arg_helper_test.rb +13 -6
- data/test/gir_ffi/boxed_base_test.rb +1 -1
- data/test/gir_ffi/builder_test.rb +3 -157
- data/test/gir_ffi/builders/argument_builder_test.rb +73 -33
- data/test/gir_ffi/builders/callback_argument_builder_test.rb +6 -2
- data/test/gir_ffi/builders/callback_return_value_builder_test.rb +5 -2
- data/test/gir_ffi/builders/constructor_builder_test.rb +3 -1
- data/test/gir_ffi/builders/field_builder_test.rb +9 -3
- data/test/gir_ffi/builders/function_builder_test.rb +30 -10
- data/test/gir_ffi/builders/initializer_builder_test.rb +3 -1
- data/test/gir_ffi/builders/object_builder_test.rb +6 -6
- data/test/gir_ffi/builders/property_builder_test.rb +5 -2
- data/test/gir_ffi/builders/return_value_builder_test.rb +20 -9
- data/test/gir_ffi/builders/signal_closure_builder_test.rb +9 -7
- data/test/gir_ffi/builders/struct_builder_test.rb +6 -3
- data/test/gir_ffi/builders/user_defined_builder_test.rb +7 -3
- data/test/gir_ffi/builders/vfunc_argument_builder_test.rb +11 -5
- data/test/gir_ffi/builders/vfunc_builder_test.rb +10 -6
- data/test/gir_ffi/class_base_test.rb +17 -12
- data/test/gir_ffi/core_test.rb +4 -3
- data/test/gir_ffi/ffi_ext/pointer_test.rb +4 -2
- data/test/gir_ffi/info_ext/i_callback_info_test.rb +2 -1
- data/test/gir_ffi/info_ext/i_type_info_test.rb +2 -1
- data/test/gir_ffi/method_stubber_test.rb +3 -1
- data/test/integration/derived_classes_test.rb +1 -0
- data/test/integration/generated_everything_test.rb +2 -1
- data/test/integration/generated_gimarshallingtests_test.rb +57 -44
- data/test/integration/generated_gtk_source_test.rb +6 -17
- data/test/integration/generated_regress_test.rb +16 -2
- data/test/integration/generated_warnlib_test.rb +4 -2
- data/test/introspection_test_helper.rb +2 -1
- metadata +22 -8
@@ -12,7 +12,8 @@ describe GirFFI::InfoExt::ICallbackInfo do
|
|
12
12
|
|
13
13
|
describe "#return_ffi_type" do
|
14
14
|
it "returns the callback ffi type of the return type" do
|
15
|
-
allow(return_type_info = Object.new)
|
15
|
+
allow(return_type_info = Object.new)
|
16
|
+
.to receive(:to_callback_ffi_type).and_return :some_type
|
16
17
|
allow(callback_info).to receive(:return_type).and_return return_type_info
|
17
18
|
|
18
19
|
_(callback_info.return_ffi_type).must_equal :some_type
|
@@ -195,7 +195,8 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
195
195
|
allow(type_info).to receive(:interface).and_return iface_info
|
196
196
|
expect(type_info).to receive(:pointer?).and_return false
|
197
197
|
|
198
|
-
expect(GirFFI::Builder)
|
198
|
+
expect(GirFFI::Builder)
|
199
|
+
.to receive(:build_class).with(iface_info).and_return interface
|
199
200
|
end
|
200
201
|
|
201
202
|
describe "when the interface type is :enum" do
|
@@ -50,7 +50,9 @@ describe GirFFI::MethodStubber do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
describe "for a method with an empty name" do
|
53
|
-
let(:method_info)
|
53
|
+
let(:method_info) do
|
54
|
+
get_method_introspection_data("Regress", "TestObj", "instance_method")
|
55
|
+
end
|
54
56
|
|
55
57
|
it "creates a method stub with a safe name that sets up the unsafe method" do
|
56
58
|
allow(method_info).to receive(:name).and_return ""
|
@@ -340,7 +340,8 @@ describe Everything do
|
|
340
340
|
end
|
341
341
|
|
342
342
|
it "has a working function #passthrough_one_GType" do
|
343
|
-
_(Everything.passthrough_one_GType(GObject::TYPE_OBJECT))
|
343
|
+
_(Everything.passthrough_one_GType(GObject::TYPE_OBJECT))
|
344
|
+
.must_equal GObject::TYPE_OBJECT
|
344
345
|
end
|
345
346
|
|
346
347
|
it "has a working function #passthrough_one_filename" do
|
@@ -357,11 +357,13 @@ describe GIMarshallingTests do
|
|
357
357
|
result = nil
|
358
358
|
|
359
359
|
derived_instance = make_derived_instance do |info|
|
360
|
-
info.install_vfunc_implementation
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
360
|
+
info.install_vfunc_implementation(
|
361
|
+
:vfunc_with_callback,
|
362
|
+
proc { |_obj, callback, callback_data|
|
363
|
+
cb = callback
|
364
|
+
user_data = callback_data.address
|
365
|
+
result = callback.call(42, callback_data)
|
366
|
+
})
|
365
367
|
end
|
366
368
|
derived_instance.call_vfunc_with_callback
|
367
369
|
|
@@ -379,9 +381,11 @@ describe GIMarshallingTests do
|
|
379
381
|
it "has a working method #get_ref_info_for_vfunc_in_object_transfer_full" do
|
380
382
|
obj = nil
|
381
383
|
derived_instance = make_derived_instance do |info|
|
382
|
-
info.install_vfunc_implementation
|
383
|
-
|
384
|
-
|
384
|
+
info.install_vfunc_implementation(
|
385
|
+
:vfunc_in_object_transfer_full,
|
386
|
+
proc { |_this, object|
|
387
|
+
obj = object
|
388
|
+
})
|
385
389
|
end
|
386
390
|
result = derived_instance
|
387
391
|
.get_ref_info_for_vfunc_in_object_transfer_full GIMarshallingTests::Object.gtype
|
@@ -392,9 +396,11 @@ describe GIMarshallingTests do
|
|
392
396
|
it "has a working method #get_ref_info_for_vfunc_in_object_transfer_none" do
|
393
397
|
obj = nil
|
394
398
|
derived_instance = make_derived_instance do |info|
|
395
|
-
info.install_vfunc_implementation
|
396
|
-
|
397
|
-
|
399
|
+
info.install_vfunc_implementation(
|
400
|
+
:vfunc_in_object_transfer_none,
|
401
|
+
proc { |_this, object|
|
402
|
+
obj = object
|
403
|
+
})
|
398
404
|
end
|
399
405
|
result = derived_instance
|
400
406
|
.get_ref_info_for_vfunc_in_object_transfer_none GIMarshallingTests::Object.gtype
|
@@ -489,9 +495,11 @@ describe GIMarshallingTests do
|
|
489
495
|
|
490
496
|
it "has a working method #method_int8_arg_and_out_callee" do
|
491
497
|
derived_instance = make_derived_instance do |info|
|
492
|
-
info.install_vfunc_implementation
|
493
|
-
|
494
|
-
|
498
|
+
info.install_vfunc_implementation(
|
499
|
+
:method_int8_arg_and_out_callee,
|
500
|
+
proc { |_obj, arg|
|
501
|
+
2 * arg
|
502
|
+
})
|
495
503
|
end
|
496
504
|
result = derived_instance.method_int8_arg_and_out_callee 32
|
497
505
|
_(result).must_equal 64
|
@@ -499,9 +507,11 @@ describe GIMarshallingTests do
|
|
499
507
|
|
500
508
|
it "has a working method #method_int8_arg_and_out_caller" do
|
501
509
|
derived_instance = make_derived_instance do |info|
|
502
|
-
info.install_vfunc_implementation
|
503
|
-
|
504
|
-
|
510
|
+
info.install_vfunc_implementation(
|
511
|
+
:method_int8_arg_and_out_caller,
|
512
|
+
proc { |_obj, arg|
|
513
|
+
2 * arg
|
514
|
+
})
|
505
515
|
end
|
506
516
|
result = derived_instance.method_int8_arg_and_out_caller 32
|
507
517
|
_(result).must_equal 64
|
@@ -524,7 +534,8 @@ describe GIMarshallingTests do
|
|
524
534
|
|
525
535
|
it "has a working method #method_str_arg_out_ret" do
|
526
536
|
derived_instance = make_derived_instance do |info|
|
527
|
-
info.install_vfunc_implementation
|
537
|
+
info.install_vfunc_implementation(:method_str_arg_out_ret,
|
538
|
+
proc { |_obj, arg| [arg, 42] })
|
528
539
|
end
|
529
540
|
_(derived_instance.method_str_arg_out_ret("foo")).must_equal ["foo", 42]
|
530
541
|
end
|
@@ -565,9 +576,11 @@ describe GIMarshallingTests do
|
|
565
576
|
|
566
577
|
it "has a working method #vfunc_caller_allocated_out_parameter" do
|
567
578
|
derived_instance = make_derived_instance do |info|
|
568
|
-
info.install_vfunc_implementation
|
569
|
-
|
570
|
-
|
579
|
+
info.install_vfunc_implementation(
|
580
|
+
:vfunc_caller_allocated_out_parameter,
|
581
|
+
proc { |_obj|
|
582
|
+
"Hello!"
|
583
|
+
})
|
571
584
|
end
|
572
585
|
result = derived_instance.vfunc_caller_allocated_out_parameter
|
573
586
|
_(result).must_equal "Hello!"
|
@@ -648,7 +661,8 @@ describe GIMarshallingTests do
|
|
648
661
|
|
649
662
|
it "has a working method #vfunc_return_value_only" do
|
650
663
|
derived_instance = make_derived_instance do |info|
|
651
|
-
info.install_vfunc_implementation
|
664
|
+
info.install_vfunc_implementation(:vfunc_return_value_only,
|
665
|
+
proc { |_obj| 0x1234_5678 })
|
652
666
|
end
|
653
667
|
result = derived_instance.vfunc_return_value_only
|
654
668
|
_(result).must_equal 0x1234_5678
|
@@ -658,9 +672,11 @@ describe GIMarshallingTests do
|
|
658
672
|
result = 1
|
659
673
|
|
660
674
|
derived_instance = make_derived_instance do |info|
|
661
|
-
info.install_vfunc_implementation
|
662
|
-
|
663
|
-
|
675
|
+
info.install_vfunc_implementation(
|
676
|
+
:vfunc_with_callback,
|
677
|
+
proc { |_obj, callback, callback_data|
|
678
|
+
callback.call(42, callback_data)
|
679
|
+
})
|
664
680
|
end
|
665
681
|
|
666
682
|
derived_instance.vfunc_with_callback { |val, user_data| result = val + user_data }
|
@@ -1696,9 +1712,10 @@ describe GIMarshallingTests do
|
|
1696
1712
|
end
|
1697
1713
|
|
1698
1714
|
it "has a working function #callback_return_value_and_multiple_out_parameters" do
|
1699
|
-
result =
|
1700
|
-
|
1701
|
-
|
1715
|
+
result =
|
1716
|
+
GIMarshallingTests.callback_return_value_and_multiple_out_parameters do |*_args|
|
1717
|
+
[42, -142, 3]
|
1718
|
+
end
|
1702
1719
|
_(result).must_equal [42, -142, 3]
|
1703
1720
|
end
|
1704
1721
|
|
@@ -1951,25 +1968,21 @@ describe GIMarshallingTests do
|
|
1951
1968
|
end
|
1952
1969
|
|
1953
1970
|
it "has a working function #gerror" do
|
1954
|
-
|
1955
|
-
|
1956
|
-
|
1957
|
-
|
1958
|
-
|
1959
|
-
|
1960
|
-
_(e.code).must_equal GIMarshallingTests::CONSTANT_GERROR_CODE
|
1961
|
-
end
|
1971
|
+
GIMarshallingTests.gerror
|
1972
|
+
flunk "Error should have been raised"
|
1973
|
+
rescue GirFFI::GLibError => e
|
1974
|
+
_(e.message).must_equal GIMarshallingTests::CONSTANT_GERROR_MESSAGE
|
1975
|
+
_(e.domain).must_equal GIMarshallingTests::CONSTANT_GERROR_DOMAIN
|
1976
|
+
_(e.code).must_equal GIMarshallingTests::CONSTANT_GERROR_CODE
|
1962
1977
|
end
|
1963
1978
|
|
1964
1979
|
it "has a working function #gerror_array_in" do
|
1965
|
-
|
1966
|
-
|
1967
|
-
|
1968
|
-
|
1969
|
-
|
1970
|
-
|
1971
|
-
_(e.code).must_equal GIMarshallingTests::CONSTANT_GERROR_CODE
|
1972
|
-
end
|
1980
|
+
GIMarshallingTests.gerror_array_in [1, 2, 3]
|
1981
|
+
flunk "Error should have been raised"
|
1982
|
+
rescue GirFFI::GLibError => e
|
1983
|
+
_(e.message).must_equal GIMarshallingTests::CONSTANT_GERROR_MESSAGE
|
1984
|
+
_(e.domain).must_equal GIMarshallingTests::CONSTANT_GERROR_DOMAIN
|
1985
|
+
_(e.code).must_equal GIMarshallingTests::CONSTANT_GERROR_CODE
|
1973
1986
|
end
|
1974
1987
|
|
1975
1988
|
it "has a working function #gerror_out" do
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "gir_ffi_test_helper"
|
4
4
|
|
5
|
-
GirFFI.setup :GtkSource
|
5
|
+
GirFFI.setup :GtkSource, "3.0"
|
6
6
|
|
7
7
|
# Tests behavior of objects in the generated GtkSource namespace.
|
8
8
|
describe "The generated GtkSource module" do
|
@@ -10,22 +10,11 @@ describe "The generated GtkSource module" do
|
|
10
10
|
let(:instance) { GtkSource::CompletionContext.new }
|
11
11
|
|
12
12
|
it "allows adding proposals" do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
item.text = "Proposal #{i}"
|
19
|
-
item.info = "blah #{i}"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
else
|
23
|
-
[
|
24
|
-
GtkSource::CompletionItem.new("Proposal 1", "Proposal 1", nil, "blah 1"),
|
25
|
-
GtkSource::CompletionItem.new("Proposal 2", "Proposal 2", nil, "blah 2"),
|
26
|
-
GtkSource::CompletionItem.new("Proposal 3", "Proposal 3", nil, "blah 3")
|
27
|
-
]
|
28
|
-
end
|
13
|
+
proposals = [
|
14
|
+
GtkSource::CompletionItem.new("Proposal 1", "Proposal 1", nil, "blah 1"),
|
15
|
+
GtkSource::CompletionItem.new("Proposal 2", "Proposal 2", nil, "blah 2"),
|
16
|
+
GtkSource::CompletionItem.new("Proposal 3", "Proposal 3", nil, "blah 3")
|
17
|
+
]
|
29
18
|
instance.add_proposals nil, proposals, true
|
30
19
|
end
|
31
20
|
end
|
@@ -1621,6 +1621,11 @@ describe Regress do
|
|
1621
1621
|
_(instance).wont_be :floating?
|
1622
1622
|
end
|
1623
1623
|
|
1624
|
+
it "defines callback type Matrix in the metaclass namespace" do
|
1625
|
+
_(Regress::TestObjClass.const_defined? :Matrix).must_equal true
|
1626
|
+
_(Regress.const_defined? :Matrix).must_equal false
|
1627
|
+
end
|
1628
|
+
|
1624
1629
|
it "has a working method #matrix" do
|
1625
1630
|
_(instance.matrix("bar")).must_equal 42
|
1626
1631
|
end
|
@@ -1674,6 +1679,13 @@ describe Regress do
|
|
1674
1679
|
instance.emit_sig_with_int64
|
1675
1680
|
end
|
1676
1681
|
|
1682
|
+
it "defines signal type Sig_with_int64_prop in the class namespace" do
|
1683
|
+
instance.signal_connect("sig-with-int64-prop") { |_obj, i, _ud| i }
|
1684
|
+
instance.emit_sig_with_int64
|
1685
|
+
_(Regress::TestObj.const_defined? :Sig_with_int64_prop).must_equal true
|
1686
|
+
_(Regress.const_defined? :Sig_with_int64_prop).must_equal false
|
1687
|
+
end
|
1688
|
+
|
1677
1689
|
it "has a working method #emit_sig_with_null_error" do
|
1678
1690
|
skip_below "1.61.1"
|
1679
1691
|
error = nil
|
@@ -3655,7 +3667,8 @@ describe Regress do
|
|
3655
3667
|
end
|
3656
3668
|
|
3657
3669
|
it "has a working function #test_glist_gtype_container_in" do
|
3658
|
-
Regress.test_glist_gtype_container_in [Regress::TestObj.gtype,
|
3670
|
+
Regress.test_glist_gtype_container_in [Regress::TestObj.gtype,
|
3671
|
+
Regress::TestSubObj.gtype]
|
3659
3672
|
pass
|
3660
3673
|
end
|
3661
3674
|
|
@@ -4057,6 +4070,7 @@ describe Regress do
|
|
4057
4070
|
|
4058
4071
|
it "raises an appropriate NoMethodError when a function is not found" do
|
4059
4072
|
result = _(proc { Regress.this_method_does_not_exist }).must_raise(NoMethodError)
|
4060
|
-
_(result.message)
|
4073
|
+
_(result.message)
|
4074
|
+
.must_equal "undefined method `this_method_does_not_exist' for Regress:Module"
|
4061
4075
|
end
|
4062
4076
|
end
|
@@ -14,8 +14,10 @@ describe "The generated WarnLib module" do
|
|
14
14
|
@result = nil
|
15
15
|
derived_klass.class_eval { include WarnLib::Whatever }
|
16
16
|
GirFFI.define_type derived_klass do |info|
|
17
|
-
info.install_vfunc_implementation :do_boo,
|
18
|
-
|
17
|
+
info.install_vfunc_implementation :do_boo,
|
18
|
+
proc { |_obj, x, _y| @result = "boo#{x}" }
|
19
|
+
info.install_vfunc_implementation :do_moo,
|
20
|
+
proc { |_obj, x, _y| @result = "moo#{x}" }
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
@@ -4,7 +4,8 @@ require "base_test_helper"
|
|
4
4
|
|
5
5
|
require "ffi-gobject_introspection"
|
6
6
|
|
7
|
-
GObjectIntrospection::IRepository
|
7
|
+
GObjectIntrospection::IRepository
|
8
|
+
.prepend_search_path File.join(File.dirname(__FILE__), "lib")
|
8
9
|
|
9
10
|
module LocalSharedLibrary
|
10
11
|
def shared_library(namespace)
|
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.15.
|
4
|
+
version: 0.15.3
|
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:
|
11
|
+
date: 2020-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 1.0.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 1.0.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: minitest
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '13.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rexml
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rspec-mocks
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +114,14 @@ dependencies:
|
|
100
114
|
requirements:
|
101
115
|
- - "~>"
|
102
116
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
117
|
+
version: 0.18.0
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
122
|
- - "~>"
|
109
123
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
124
|
+
version: 0.18.0
|
111
125
|
description: |2
|
112
126
|
GirFFI creates bindings for GObject-based libraries at runtime based on introspection
|
113
127
|
data provided by the GObject Introspection Repository (GIR) system. Bindings are created
|
@@ -443,14 +457,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
443
457
|
requirements:
|
444
458
|
- - ">="
|
445
459
|
- !ruby/object:Gem::Version
|
446
|
-
version: 2.
|
460
|
+
version: 2.5.0
|
447
461
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
448
462
|
requirements:
|
449
463
|
- - ">="
|
450
464
|
- !ruby/object:Gem::Version
|
451
465
|
version: '0'
|
452
466
|
requirements: []
|
453
|
-
rubygems_version: 3.
|
467
|
+
rubygems_version: 3.1.2
|
454
468
|
signing_key:
|
455
469
|
specification_version: 4
|
456
470
|
summary: FFI-based GObject binding using the GObject Introspection Repository
|