gobject-introspection 3.4.3 → 3.4.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/ext/gobject-introspection/extconf.rb +1 -4
  3. data/ext/gobject-introspection/gobject-introspection-enum-types.c +230 -0
  4. data/ext/gobject-introspection/gobject-introspection-enum-types.h +42 -0
  5. data/ext/gobject-introspection/rb-gi-argument.c +11 -4
  6. data/ext/gobject-introspection/rb-gi-arguments-in.c +28 -108
  7. data/ext/gobject-introspection/rb-gi-arguments-out.c +20 -2
  8. data/ext/gobject-introspection/rb-gi-arguments.c +244 -18
  9. data/ext/gobject-introspection/rb-gi-base-info.c +11 -1
  10. data/ext/gobject-introspection/rb-gi-callable-info.c +10 -2
  11. data/ext/gobject-introspection/rb-gi-callback.c +156 -2
  12. data/ext/gobject-introspection/rb-gi-conversions.h +6 -6
  13. data/ext/gobject-introspection/rb-gi-interface-info.c +1 -7
  14. data/ext/gobject-introspection/rb-gi-loader.c +60 -12
  15. data/ext/gobject-introspection/rb-gi-object-info.c +11 -1
  16. data/ext/gobject-introspection/rb-gi-private-arguments-in.h +3 -1
  17. data/ext/gobject-introspection/rb-gi-private-arguments.h +5 -1
  18. data/ext/gobject-introspection/rb-gi-private-callback.h +6 -3
  19. data/ext/gobject-introspection/rb-gi-private.h +1 -0
  20. data/ext/gobject-introspection/rb-gi-repository.c +1 -1
  21. data/ext/gobject-introspection/rb-gi-struct-info.c +15 -3
  22. data/ext/gobject-introspection/rb-gi-vfunc-info.c +2 -2
  23. data/ext/gobject-introspection/rb-gobject-introspection.c +231 -0
  24. data/ext/gobject-introspection/rbgiversion.h +24 -0
  25. data/lib/gobject-introspection/loader.rb +65 -1
  26. data/test/gobject-introspection-test-utils.rb +2 -2
  27. data/test/run-test.rb +18 -25
  28. data/test/test-base-info.rb +5 -1
  29. data/test/test-callable-info.rb +16 -2
  30. data/test/test-loader.rb +53 -7
  31. data/test/test-object-info.rb +5 -1
  32. data/test/test-struct-info.rb +6 -1
  33. metadata +8 -5
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2012-2019 Ruby-GNOME Project Team
1
+ # Copyright (C) 2012-2021 Ruby-GNOME Project Team
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -216,6 +216,7 @@ module GObjectIntrospection
216
216
  klass = self.class.define_class(info.gtype,
217
217
  rubyish_class_name(info),
218
218
  @base_module)
219
+ load_virtual_functions(info, klass)
219
220
  load_fields(info, klass)
220
221
  load_methods(info, klass)
221
222
  end
@@ -338,6 +339,20 @@ module GObjectIntrospection
338
339
  end
339
340
  end
340
341
 
342
+ def load_virtual_functions(info, klass)
343
+ klass.extend(VirtualFunctionImplementable)
344
+ gtype_prefix = rubyish_gtype_name(klass.gtype.name)
345
+ implementor = VirtualFunctionImplementor.new(self.class,
346
+ gtype_prefix,
347
+ info.vfuncs)
348
+ klass.__send__(:initialize_virtual_function_implementable,
349
+ implementor)
350
+ end
351
+
352
+ def rubyish_gtype_name(name)
353
+ name.scan(/[A-Z]+[a-z\d]+/).collect(&:downcase).join("_")
354
+ end
355
+
341
356
  def initialize_post(object)
342
357
  end
343
358
 
@@ -546,6 +561,7 @@ module GObjectIntrospection
546
561
  self.class.define_interface(info.gtype,
547
562
  rubyish_class_name(info),
548
563
  @base_module)
564
+ load_virtual_functions(info, interface_module)
549
565
  load_methods(info, interface_module)
550
566
  end
551
567
 
@@ -708,5 +724,53 @@ module GObjectIntrospection
708
724
  "#{@full_method_name}: wrong number of arguments (#{detail})"
709
725
  end
710
726
  end
727
+
728
+ class VirtualFunctionImplementor
729
+ def initialize(loader_class, gtype_prefix, infos)
730
+ @loader_class = loader_class
731
+ @gtype_prefix = gtype_prefix
732
+ @infos = {}
733
+ prefix = GLib::VIRTUAL_FUNCTION_IMPLEMENTATION_PREFIX
734
+ infos.each do |info|
735
+ name = info.name
736
+ @infos[:"#{prefix}#{name}"] = info
737
+ @infos[:"#{prefix}#{gtype_prefix}_#{name}"] = info
738
+ end
739
+ end
740
+
741
+ def implement(implementor_gtype, name)
742
+ info = @infos[name]
743
+ return false if info.nil?
744
+ container = info.container
745
+ vtable_gtype = container.gtype
746
+ if container.respond_to?(:class_struct)
747
+ struct = container.class_struct
748
+ else
749
+ return false unless implementor_gtype.type_is_a?(vtable_gtype)
750
+ struct = container.iface_struct
751
+ end
752
+ field = struct.find_field(info.name)
753
+ @loader_class.implement_virtual_function(field,
754
+ implementor_gtype,
755
+ vtable_gtype,
756
+ name.to_s)
757
+ true
758
+ end
759
+ end
760
+
761
+ module VirtualFunctionImplementable
762
+ def initialize_virtual_function_implementable(implementor)
763
+ @virtual_function_implementor = implementor
764
+ end
765
+
766
+ def implement_virtual_function(implementor_class, name)
767
+ unless instance_variable_defined?(:@virtual_function_implementor)
768
+ return false
769
+ end
770
+ @virtual_function_implementor.implement(implementor_class.gtype,
771
+ name)
772
+ true
773
+ end
774
+ end
711
775
  end
712
776
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2012 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2012-2021 Ruby-GNOME Project Team
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -14,7 +14,7 @@
14
14
  # License along with this library; if not, write to the Free Software
15
15
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
- require "test-unit"
17
+ require "gobject-introspection"
18
18
 
19
19
  module GObjectIntrospectionTestUtils
20
20
  def require_version(major, minor, micro)
data/test/run-test.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
- # Copyright (C) 2012-2020 Ruby-GNOME Project Team
3
+ # Copyright (C) 2012-2021 Ruby-GNOME Project Team
4
4
  #
5
5
  # This library is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the GNU Lesser General Public
@@ -16,31 +16,24 @@
16
16
  # License along with this library; if not, write to the Free Software
17
17
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
18
 
19
- ruby_gnome_base = File.join(File.dirname(__FILE__), "..", "..")
20
- ruby_gnome_base = File.expand_path(ruby_gnome_base)
19
+ require_relative "../../glib2/test/run-test"
21
20
 
22
- glib_base = File.join(ruby_gnome_base, "glib2")
23
- gobject_introspection_base = File.join(ruby_gnome_base, "gobject-introspection")
21
+ run_test(__dir__,
22
+ [
23
+ "glib2",
24
+ "gobject-introspection",
25
+ ]) do |context|
26
+ require_relative "gobject-introspection-test-utils"
24
27
 
25
- modules = [
26
- [glib_base, "glib2"],
27
- [gobject_introspection_base, "gobject-introspection"]
28
- ]
29
- modules.each do |target, module_name|
30
- if File.exist?("#{target}/Makefile") and system("which make > /dev/null")
31
- `make -C #{target.dump} > /dev/null` or exit(false)
28
+ begin
29
+ repository = GObjectIntrospection::Repository.default
30
+ repository.require("Gio")
31
+ rescue GObjectIntrospection::RepositoryError
32
+ puts("Omit because typelib file doesn't exist: #{$!.message}")
33
+ exit(true)
32
34
  end
33
- $LOAD_PATH.unshift(File.join(target, "ext", module_name))
34
- $LOAD_PATH.unshift(File.join(target, "lib"))
35
- end
36
-
37
- $LOAD_PATH.unshift(File.join(glib_base, "test"))
38
- require "glib-test-init"
39
-
40
- $LOAD_PATH.unshift(File.join(gobject_introspection_base, "test"))
41
- require "gobject-introspection-test-utils"
42
35
 
43
- require "gobject-introspection"
44
-
45
- exit Test::Unit::AutoRunner.run(true,
46
- File.join(gobject_introspection_base, "test"))
36
+ module Gio
37
+ GObjectIntrospection::Loader.load("Gio", self)
38
+ end
39
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2012 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2012-2021 Ruby-GNOME Project Team
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -28,4 +28,8 @@ class TestBaseInfo < Test::Unit::TestCase
28
28
  def test_namespace
29
29
  assert_equal("GObject", @info.namespace)
30
30
  end
31
+
32
+ def test_container
33
+ assert_equal("Object", @info.vfuncs.first.container.name)
34
+ end
31
35
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2012 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2012-2021 Ruby-GNOME Project Team
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -21,6 +21,12 @@ class TestCallableInfo < Test::Unit::TestCase
21
21
  @info = @repository.find("GObject", "signal_name")
22
22
  end
23
23
 
24
+ def test_can_throw_gerror
25
+ assert do
26
+ not @info.can_throw_gerror?
27
+ end
28
+ end
29
+
24
30
  def test_return_type
25
31
  assert_kind_of(GObjectIntrospection::TypeInfo,
26
32
  @info.return_type)
@@ -32,7 +38,15 @@ class TestCallableInfo < Test::Unit::TestCase
32
38
  end
33
39
 
34
40
  def test_may_return_null?
35
- assert_false(@info.may_return_null?)
41
+ if GObjectIntrospection::Version.or_later?(1, 67, 0)
42
+ assert do
43
+ @info.may_return_null?
44
+ end
45
+ else
46
+ assert do
47
+ not @info.may_return_null?
48
+ end
49
+ end
36
50
  end
37
51
 
38
52
  def test_n_args
data/test/test-loader.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2012 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2012-2021 Ruby-GNOME Project Team
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -17,14 +17,60 @@
17
17
  class TestLoaderInfo < Test::Unit::TestCase
18
18
  def setup
19
19
  @repository = GObjectIntrospection::Repository.default
20
- @repository.require("Gio")
21
- @info = @repository.find("Gio", "Application")
22
- @sandbox = Module.new
23
20
  end
24
21
 
25
22
  def test_define_class
26
- gtype = @info.gtype
27
- GObjectIntrospection::Loader.define_class(gtype, "Application", @sandbox)
28
- assert_equal(gtype, @sandbox::Application.gtype)
23
+ info = @repository.find("Gio", "Application")
24
+ gtype = info.gtype
25
+ assert_equal(gtype, Gio::Application.gtype)
26
+ end
27
+
28
+ sub_test_case("virtual function") do
29
+ def test_without_prefix
30
+ active_vfs_class = Class.new(Gio::Vfs) do
31
+ type_register("ActiveVfsWithoutPrefix")
32
+
33
+ def virtual_do_is_active
34
+ true
35
+ end
36
+ end
37
+ active_vfs = active_vfs_class.new
38
+ assert do
39
+ active_vfs.active?
40
+ end
41
+ end
42
+
43
+ def test_with_prefix
44
+ active_vfs_class = Class.new(Gio::Vfs) do
45
+ type_register("ActiveVfsWithPrefix")
46
+
47
+ def virtual_do_gvfs_is_active
48
+ true
49
+ end
50
+ end
51
+ active_vfs = active_vfs_class.new
52
+ assert do
53
+ active_vfs.active?
54
+ end
55
+ end
56
+
57
+ def test_interface
58
+ resettable_converter_class = Class.new(GLib::Object) do
59
+ type_register("ResettableConverter")
60
+
61
+ include Gio::Converter
62
+
63
+ attr_reader :resetted
64
+
65
+ def virtual_do_reset
66
+ @resetted = true
67
+ end
68
+ end
69
+ resettable_converter = resettable_converter_class.new
70
+ resettable_converter.reset
71
+ assert do
72
+ resettable_converter.resetted
73
+ end
74
+ end
29
75
  end
30
76
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2012 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2012-2021 Ruby-GNOME Project Team
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -113,6 +113,10 @@ class TestObjectInfo < Test::Unit::TestCase
113
113
  assert_equal(0, @info.n_constants)
114
114
  end
115
115
 
116
+ def test_class_struct
117
+ assert_equal("FileOutputStreamClass", @info.class_struct.name)
118
+ end
119
+
116
120
  def test_unref_function
117
121
  assert_nil(@info.unref_function)
118
122
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2012-2014 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2012-2021 Ruby-GNOME Project Team
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -30,6 +30,11 @@ class TestStructInfo < Test::Unit::TestCase
30
30
  @info.get_field(0))
31
31
  end
32
32
 
33
+ def test_find_field
34
+ assert_equal("g_type",
35
+ @info.find_field("g_type").name)
36
+ end
37
+
33
38
  def test_n_methods
34
39
  assert_operator(@info.n_methods, :>=, 62)
35
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gobject-introspection
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.3
4
+ version: 3.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Ruby-GNOME Project Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-10 00:00:00.000000000 Z
11
+ date: 2021-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glib2
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 3.4.3
19
+ version: 3.4.9
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 3.4.3
26
+ version: 3.4.9
27
27
  description: Ruby/GObjectIntrospection provides bindings of GObject Introspection
28
28
  and a loader module that can generate dynamically Ruby bindings of any GObject C
29
29
  libraries
@@ -38,6 +38,8 @@ files:
38
38
  - Rakefile
39
39
  - ext/gobject-introspection/depend
40
40
  - ext/gobject-introspection/extconf.rb
41
+ - ext/gobject-introspection/gobject-introspection-enum-types.c
42
+ - ext/gobject-introspection/gobject-introspection-enum-types.h
41
43
  - ext/gobject-introspection/gobject_introspection.def
42
44
  - ext/gobject-introspection/rb-gi-arg-info.c
43
45
  - ext/gobject-introspection/rb-gi-argument.c
@@ -86,6 +88,7 @@ files:
86
88
  - ext/gobject-introspection/rb-gi-vfunc-info.c
87
89
  - ext/gobject-introspection/rb-gobject-introspection.c
88
90
  - ext/gobject-introspection/rb-gobject-introspection.h
91
+ - ext/gobject-introspection/rbgiversion.h
89
92
  - extconf.rb
90
93
  - gobject-introspection.gemspec
91
94
  - lib/gi.rb
@@ -151,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
154
  - !ruby/object:Gem::Version
152
155
  version: '0'
153
156
  requirements: []
154
- rubygems_version: 3.2.0.pre1
157
+ rubygems_version: 3.3.0.dev
155
158
  signing_key:
156
159
  specification_version: 4
157
160
  summary: Ruby/GObjectIntrospection is a Ruby binding of GObject Introspection.