gir_ffi 0.15.4 → 0.15.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +23 -0
- data/README.md +8 -23
- data/lib/ffi-glib/container_class_methods.rb +1 -3
- data/lib/ffi-glib/hash_table.rb +1 -1
- data/lib/ffi-gobject/object.rb +36 -50
- data/lib/ffi-gobject/ruby_closure.rb +1 -1
- data/lib/ffi-gobject/value.rb +0 -10
- data/lib/ffi-gobject.rb +3 -3
- data/lib/ffi-gobject_introspection/i_base_info.rb +17 -10
- data/lib/gir_ffi/array_element_convertor.rb +2 -2
- data/lib/gir_ffi/boxed_base.rb +12 -6
- data/lib/gir_ffi/builder.rb +2 -3
- data/lib/gir_ffi/builders/argument_builder_collection.rb +5 -1
- data/lib/gir_ffi/builders/function_builder.rb +1 -1
- data/lib/gir_ffi/builders/interface_builder.rb +2 -2
- data/lib/gir_ffi/builders/module_builder.rb +2 -2
- data/lib/gir_ffi/builders/object_builder.rb +8 -6
- data/lib/gir_ffi/builders/struct_builder.rb +31 -6
- data/lib/gir_ffi/builders/user_defined_builder.rb +1 -1
- data/lib/gir_ffi/callback_base.rb +1 -0
- data/lib/gir_ffi/core.rb +1 -1
- data/lib/gir_ffi/in_pointer.rb +3 -2
- data/lib/gir_ffi/info_ext/i_type_info.rb +2 -1
- data/lib/gir_ffi/interface_base.rb +5 -0
- data/lib/gir_ffi/type_map.rb +1 -0
- data/lib/gir_ffi/version.rb +1 -1
- metadata +34 -20
- data/lib/gir_ffi/builders/class_struct_builder.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7c0566bc2fcd7e7b5ab1381448f4738fdebd617743c524ea18c343e1d3fbce5
|
4
|
+
data.tar.gz: 5008632e7cd2fa2190c12f056257f68a94b03fa4a8f225df54fae006b6127db1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a0f1e2330171a92b26a1c476e0c5b7beaeb2e38e6e0e81d9bb47247b74b02ed7e0e5261c2e7adf33f93860b284e2eddf61a938c584c5cccaab69b2b85d5109c
|
7
|
+
data.tar.gz: ddb889010ccc55495ffb306e3996fa6ce37367bbc65ff78f0024df244b3663691879be7f78c53c9543f90b4360dfca35b47bf35a9acf7382271a685aea542cbe
|
data/Changelog.md
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.15.8 / 2021-11-20
|
4
|
+
|
5
|
+
* Drop support for Ruby 2.5
|
6
|
+
* Bump minimum supported version of gobject-introspection to 1.56.0
|
7
|
+
* Bump minimum supported version of glib to 2.56.0
|
8
|
+
* Handle functions that have swapped closure annotation
|
9
|
+
* Handle GPtrArray arguments in signal handlers
|
10
|
+
|
11
|
+
## 0.15.7 / 2021-01-15
|
12
|
+
|
13
|
+
* Handle sized arrays with interface element types
|
14
|
+
|
15
|
+
## 0.15.6 / 2021-01-10
|
16
|
+
|
17
|
+
* Officially support Ruby 3.0
|
18
|
+
* Rely on `GObject.boxed_free` to free GValue objects
|
19
|
+
* Require 'set' in `callback_base.rb`, which needs it (thanks, Jordan Webb!)
|
20
|
+
* Make SizedArray handle `:filename` elements
|
21
|
+
|
22
|
+
## 0.15.5 / 2020-11-13
|
23
|
+
|
24
|
+
* Make building and finding metaclasses via `Builder.build_class` work again
|
25
|
+
|
3
26
|
## 0.15.4 / 2020-11-01
|
4
27
|
|
5
28
|
* Support disguised object class structs
|
data/README.md
CHANGED
@@ -9,10 +9,9 @@ Ruby bindings for GNOME using the GObject Introspection Repository.
|
|
9
9
|
## Status
|
10
10
|
|
11
11
|
[![Gem Version](https://badge.fury.io/rb/gir_ffi.svg)](http://badge.fury.io/rb/gir_ffi)
|
12
|
-
[![
|
13
|
-
[![Build Status](https://travis-ci.org/mvz/gir_ffi.svg?branch=master)](https://travis-ci.org/mvz/gir_ffi)
|
12
|
+
[![Build Status](https://github.com/mvz/gir_ffi/actions/workflows/ruby.yml/badge.svg)](https://github.com/mvz/gir_ffi/actions/workflows/ruby.yml)
|
14
13
|
[![Code Climate](https://codeclimate.com/github/mvz/gir_ffi/badges/gpa.svg)](https://codeclimate.com/github/mvz/gir_ffi)
|
15
|
-
[![Documentation Status](https://inch-ci.org/github/mvz/gir_ffi.svg?branch=master)](https://inch-ci.org/github/mvz/gir_ffi
|
14
|
+
[![Documentation Status](https://inch-ci.org/github/mvz/gir_ffi.svg?branch=master)](https://inch-ci.org/github/mvz/gir_ffi)
|
16
15
|
|
17
16
|
## Features
|
18
17
|
|
@@ -52,7 +51,7 @@ examples can be found in `gir_ffi-gtk` and `gir_ffi-gst`.
|
|
52
51
|
|
53
52
|
## Requirements
|
54
53
|
|
55
|
-
GirFFI is supported on CRuby 2.
|
54
|
+
GirFFI is supported on CRuby 2.6, 2.7 and 3.0, and JRuby 9.3.
|
56
55
|
|
57
56
|
You will also need gobject-introspection installed with some
|
58
57
|
introspection data.
|
@@ -62,7 +61,8 @@ available under the name ending in plain `.so`. If GirFFI complains that it
|
|
62
61
|
cannot find the library, try installing development packages for those
|
63
62
|
libraries.
|
64
63
|
|
65
|
-
GirFFI should work with gobject-introspection 1.
|
64
|
+
GirFFI should work with gobject-introspection 1.56.0 and up, and glib 2.56.0
|
65
|
+
and up.
|
66
66
|
|
67
67
|
On Debian and Ubuntu, installing `libgirepository-1.0-1` and `gir1.2-glib-2.0`
|
68
68
|
should be enough to use GirFFI in your application.
|
@@ -89,24 +89,9 @@ already exist:
|
|
89
89
|
* `gir_ffi-tracker`: overrides for Tracker
|
90
90
|
* `gir_ffi-gst`: overrides for GStreamer
|
91
91
|
|
92
|
-
##
|
92
|
+
## Contributing
|
93
93
|
|
94
|
-
Please
|
95
|
-
|
96
|
-
If you just want to help out but don't know where to start, have a look at
|
97
|
-
TODO.md, and check the notes in the code (e.g., using `dnote`).
|
98
|
-
|
99
|
-
If you want to send pull requests or patches, try to follow the instructions
|
100
|
-
below. **If you get stuck, please make a pull request anyway and I'll try to
|
101
|
-
help out.**
|
102
|
-
|
103
|
-
* Make sure `rake test` runs without reporting any failures.
|
104
|
-
* Add tests for your feature. Otherwise, I can't see if it works or if I
|
105
|
-
break it later.
|
106
|
-
* Make sure latest master merges cleanly with your branch. Things might
|
107
|
-
have moved around since you forked.
|
108
|
-
* Try not to include changes that are irrelevant to your feature in the
|
109
|
-
same commit.
|
94
|
+
Please see [CONTRIBUTING.md](CONTRIBUTING.md) for contribution guidelines.
|
110
95
|
|
111
96
|
## Contributors
|
112
97
|
|
@@ -119,7 +104,7 @@ The following people have contributed to GirFFI over the years:
|
|
119
104
|
|
120
105
|
## License
|
121
106
|
|
122
|
-
Copyright © 2009–
|
107
|
+
Copyright © 2009–2021 [Matijs van Zuijlen](http://www.matijs.net)
|
123
108
|
|
124
109
|
GirFFI is free software, distributed under the terms of the GNU Lesser
|
125
110
|
General Public License, version 2.1 or later. See the file COPYING.LIB for
|
data/lib/ffi-glib/hash_table.rb
CHANGED
data/lib/ffi-gobject/object.rb
CHANGED
@@ -7,60 +7,40 @@ GObject.load_class :Object
|
|
7
7
|
module GObject
|
8
8
|
# Overrides for GObject, GObject's generic base class.
|
9
9
|
class Object
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
10
|
+
GObject::Lib.attach_function(:g_object_new_with_properties,
|
11
|
+
[:size_t, :uint32, :pointer, :pointer],
|
12
|
+
:pointer)
|
13
|
+
|
14
|
+
def self.new_with_properties(*args, &block)
|
15
|
+
obj = allocate
|
16
|
+
obj.__send__ :initialize_with_properties, *args, &block
|
17
|
+
obj
|
18
|
+
end
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
# Starting with GLib 2.54.0, use g_object_new_with_properties, which
|
21
|
+
# takes an array of names and an array of values.
|
22
|
+
def initialize_with_properties(properties = {})
|
23
|
+
names, gvalues = names_and_gvalues_for_properties(properties)
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
n_properties = names.length
|
26
|
+
names_arr = GirFFI::SizedArray.from(:utf8, -1, names)
|
27
|
+
gvalues_arr = GirFFI::SizedArray.from(GObject::Value, -1, gvalues)
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
ptr = GObject::Lib.g_object_new_with_properties(self.class.gtype,
|
30
|
+
n_properties,
|
31
|
+
names_arr,
|
32
|
+
gvalues_arr)
|
33
|
+
store_pointer ptr
|
34
|
+
end
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
alias old_initialze initialize
|
37
|
+
alias initialize initialize_with_properties
|
38
|
+
remove_method :old_initialze
|
40
39
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
46
|
-
else
|
47
|
-
setup_method! "new"
|
48
|
-
|
49
|
-
# Before GLib 2.54.0, use g_object_newv, which takes an array of GParameter.
|
50
|
-
def initialize_with_automatic_gtype(properties = {})
|
51
|
-
gparameters = properties.map do |name, value|
|
52
|
-
name = name.to_s
|
53
|
-
property_param_spec(name)
|
54
|
-
GObject::Parameter.new.tap do |gparam|
|
55
|
-
gparam.name = name
|
56
|
-
gparam.value = value
|
57
|
-
end
|
58
|
-
end
|
59
|
-
initialize_without_automatic_gtype(self.class.gtype, gparameters)
|
60
|
-
end
|
61
|
-
|
62
|
-
alias initialize_without_automatic_gtype initialize
|
63
|
-
alias initialize initialize_with_automatic_gtype
|
40
|
+
def self.new(*args, &block)
|
41
|
+
obj = allocate
|
42
|
+
obj.__send__ :initialize, *args, &block
|
43
|
+
obj
|
64
44
|
end
|
65
45
|
|
66
46
|
alias base_initialize initialize
|
@@ -75,7 +55,13 @@ module GObject
|
|
75
55
|
end
|
76
56
|
|
77
57
|
def self.make_finalizer(ptr)
|
78
|
-
proc
|
58
|
+
proc { finalize ptr }
|
59
|
+
end
|
60
|
+
|
61
|
+
class << self
|
62
|
+
protected
|
63
|
+
|
64
|
+
def finalize(ptr)
|
79
65
|
rc = GObject::Object::Struct.new(ptr)[:ref_count]
|
80
66
|
if rc == 0
|
81
67
|
warn "not unreffing #{name}:#{ptr} (#{rc})"
|
data/lib/ffi-gobject/value.rb
CHANGED
@@ -7,16 +7,6 @@ module GObject
|
|
7
7
|
class Value
|
8
8
|
setup_instance_method! :init
|
9
9
|
|
10
|
-
def self.make_finalizer(struct)
|
11
|
-
proc do
|
12
|
-
if struct.owned?
|
13
|
-
ptr = struct.to_ptr
|
14
|
-
Lib.g_value_unset ptr unless struct[:g_type] == TYPE_INVALID
|
15
|
-
GObject.boxed_free gtype, ptr
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
10
|
METHOD_MAP = {
|
21
11
|
TYPE_INVALID => [:get_none, :set_none],
|
22
12
|
# TYPE_NONE is skipped
|
data/lib/ffi-gobject.rb
CHANGED
@@ -63,13 +63,13 @@ module GObject
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def self.signal_connect(object, detailed_signal, data = nil, after = false, &block)
|
66
|
-
raise ArgumentError, "Block needed"
|
66
|
+
block or raise ArgumentError, "Block needed"
|
67
67
|
|
68
68
|
signal_name, = detailed_signal.split("::")
|
69
69
|
sig_info = object.class.find_signal signal_name
|
70
70
|
|
71
71
|
closure = sig_info.wrap_in_closure do |*args|
|
72
|
-
|
72
|
+
yield(*args << data)
|
73
73
|
end
|
74
74
|
|
75
75
|
signal_connect_closure object, detailed_signal, closure, after
|
@@ -86,7 +86,7 @@ module GObject
|
|
86
86
|
load_class :ParamFlags
|
87
87
|
|
88
88
|
# NOTE: This Lib module is set up in `gir_ffi-base/gobject/lib.rb`.
|
89
|
-
|
89
|
+
Lib.class_eval do
|
90
90
|
attach_function :g_object_ref_sink, [:pointer], :pointer
|
91
91
|
attach_function :g_object_ref, [:pointer], :pointer
|
92
92
|
attach_function :g_object_unref, [:pointer], :pointer
|
@@ -4,19 +4,26 @@ module GObjectIntrospection
|
|
4
4
|
# Wraps GIBaseInfo struct, the base \type for all info types.
|
5
5
|
# Decendant types will be implemented as needed.
|
6
6
|
class IBaseInfo
|
7
|
-
def initialize(ptr
|
7
|
+
def initialize(ptr)
|
8
8
|
raise ArgumentError, "ptr must not be null" if ptr.null?
|
9
9
|
|
10
|
-
ObjectSpace.define_finalizer self, self.class.make_finalizer(
|
10
|
+
ObjectSpace.define_finalizer self, self.class.make_finalizer(ptr)
|
11
11
|
|
12
12
|
@pointer = ptr
|
13
|
-
@lib = lib
|
14
13
|
end
|
15
14
|
|
16
15
|
attr_reader :pointer
|
17
16
|
|
18
|
-
def self.make_finalizer(
|
19
|
-
proc {
|
17
|
+
def self.make_finalizer(ptr)
|
18
|
+
proc { finalize ptr }
|
19
|
+
end
|
20
|
+
|
21
|
+
class << self
|
22
|
+
protected
|
23
|
+
|
24
|
+
def finalize(ptr)
|
25
|
+
Lib.g_base_info_unref ptr
|
26
|
+
end
|
20
27
|
end
|
21
28
|
|
22
29
|
def to_ptr
|
@@ -42,7 +49,7 @@ module GObjectIntrospection
|
|
42
49
|
method = method.to_s
|
43
50
|
cache_ivar = "@#{method}_cache"
|
44
51
|
single ||= method[0..-2]
|
45
|
-
count = method.sub(/^(get_)?/,
|
52
|
+
count = method.sub(/^(get_)?/, "\\1n_")
|
46
53
|
class_eval <<-CODE, __FILE__, __LINE__ + 1
|
47
54
|
def #{method} # def fields
|
48
55
|
#{cache_ivar} ||= # @fields_cache ||=
|
@@ -110,10 +117,10 @@ module GObjectIntrospection
|
|
110
117
|
def container
|
111
118
|
@container ||= begin
|
112
119
|
ptr = Lib.g_base_info_get_container self
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
120
|
+
unless ptr.null?
|
121
|
+
Lib.g_base_info_ref ptr
|
122
|
+
IRepository.wrap_ibaseinfo_pointer ptr
|
123
|
+
end
|
117
124
|
end
|
118
125
|
end
|
119
126
|
|
@@ -14,11 +14,11 @@ module GirFFI
|
|
14
14
|
def to_ruby_value
|
15
15
|
bare_value = to_value
|
16
16
|
case value_type
|
17
|
-
when :utf8
|
17
|
+
when :utf8, :filename
|
18
18
|
bare_value.to_utf8
|
19
19
|
when Array
|
20
20
|
value_type[1].wrap bare_value
|
21
|
-
when
|
21
|
+
when Module
|
22
22
|
value_type.wrap bare_value
|
23
23
|
else
|
24
24
|
bare_value
|
data/lib/gir_ffi/boxed_base.rb
CHANGED
@@ -6,12 +6,7 @@ module GirFFI
|
|
6
6
|
# Base class for generated classes representing boxed types.
|
7
7
|
class BoxedBase < StructLikeBase
|
8
8
|
def self.make_finalizer(struct)
|
9
|
-
proc
|
10
|
-
if struct.owned?
|
11
|
-
struct.owned = nil
|
12
|
-
GObject.boxed_free gtype, struct.to_ptr
|
13
|
-
end
|
14
|
-
end
|
9
|
+
proc { finalize(struct) }
|
15
10
|
end
|
16
11
|
|
17
12
|
def self.copy(val)
|
@@ -19,6 +14,17 @@ module GirFFI
|
|
19
14
|
wrap(ptr)
|
20
15
|
end
|
21
16
|
|
17
|
+
class << self
|
18
|
+
protected
|
19
|
+
|
20
|
+
def finalize(struct)
|
21
|
+
struct.owned? or return
|
22
|
+
|
23
|
+
struct.owned = nil
|
24
|
+
GObject.boxed_free gtype, struct.to_ptr
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
22
28
|
private
|
23
29
|
|
24
30
|
def store_pointer(*)
|
data/lib/gir_ffi/builder.rb
CHANGED
@@ -23,9 +23,8 @@ module GirFFI
|
|
23
23
|
fund = GObject.type_fundamental gtype
|
24
24
|
if fund == GObject::TYPE_BOXED
|
25
25
|
UnintrospectableBoxedInfo.new gtype
|
26
|
-
elsif fund == GObject::TYPE_OBJECT
|
27
|
-
|
28
|
-
elsif fund >= GObject::TYPE_RESERVED_USER_FIRST
|
26
|
+
elsif fund == GObject::TYPE_OBJECT ||
|
27
|
+
fund >= GObject::TYPE_RESERVED_USER_FIRST
|
29
28
|
UnintrospectableTypeInfo.new gtype
|
30
29
|
else
|
31
30
|
raise "Unable to handle type #{GObject.type_name gtype}"
|
@@ -75,7 +75,11 @@ module GirFFI
|
|
75
75
|
def set_up_user_data_relations
|
76
76
|
@base_argument_builders.each do |bldr|
|
77
77
|
if (idx = bldr.closure_idx) >= 0
|
78
|
-
@base_argument_builders[idx]
|
78
|
+
target_bldr = @base_argument_builders[idx]
|
79
|
+
unless target_bldr.specialized_type_tag == :void
|
80
|
+
target_bldr, bldr = bldr, target_bldr
|
81
|
+
end
|
82
|
+
target_bldr.mark_as_user_data bldr
|
79
83
|
end
|
80
84
|
end
|
81
85
|
end
|
@@ -39,7 +39,7 @@ module GirFFI
|
|
39
39
|
def receiver_call_argument
|
40
40
|
container_type_info = ReceiverTypeInfo.new(container_info)
|
41
41
|
if @info.instance_ownership_transfer == :everything &&
|
42
|
-
|
42
|
+
container_type_info.flattened_tag == :object
|
43
43
|
"self.ref"
|
44
44
|
else
|
45
45
|
"self"
|
@@ -9,8 +9,8 @@ module GirFFI
|
|
9
9
|
class InterfaceBuilder < RegisteredTypeBuilder
|
10
10
|
def interface_struct
|
11
11
|
@interface_struct ||=
|
12
|
-
|
13
|
-
|
12
|
+
StructBuilder.new(iface_struct_info,
|
13
|
+
superclass: GObject::TypeInterface).build_class
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
@@ -43,7 +43,7 @@ module GirFFI
|
|
43
43
|
def find_namespaced_class_info(classname)
|
44
44
|
name = classname.to_s
|
45
45
|
info = gir.find_by_name(@namespace, name) ||
|
46
|
-
|
46
|
+
gir.find_by_name(@namespace, name.sub(/^./, &:downcase))
|
47
47
|
unless info
|
48
48
|
raise NameError,
|
49
49
|
"Class #{classname} not found in namespace #{@namespace}"
|
@@ -89,7 +89,7 @@ module GirFFI
|
|
89
89
|
lib.extend FFI::BitMasks
|
90
90
|
lib.ffi_lib_flags :global, :lazy
|
91
91
|
if shared_library_specification
|
92
|
-
lib.ffi_lib(*shared_library_specification.split(
|
92
|
+
lib.ffi_lib(*shared_library_specification.split(","))
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
@@ -3,7 +3,6 @@
|
|
3
3
|
require "gir_ffi/builders/registered_type_builder"
|
4
4
|
require "gir_ffi/builders/with_layout"
|
5
5
|
require "gir_ffi/builders/property_builder"
|
6
|
-
require "gir_ffi/builders/class_struct_builder"
|
7
6
|
require "gir_ffi/object_base"
|
8
7
|
require "gir_ffi/struct"
|
9
8
|
|
@@ -38,11 +37,14 @@ module GirFFI
|
|
38
37
|
|
39
38
|
def object_class_struct
|
40
39
|
@object_class_struct ||=
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
40
|
+
begin
|
41
|
+
parent_struct = parent_builder.object_class_struct
|
42
|
+
if object_class_struct_info
|
43
|
+
StructBuilder.new(object_class_struct_info,
|
44
|
+
superclass: parent_struct).build_class
|
45
|
+
else
|
46
|
+
parent_struct
|
47
|
+
end
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
@@ -10,23 +10,48 @@ module GirFFI
|
|
10
10
|
class StructBuilder < RegisteredTypeBuilder
|
11
11
|
include StructLike
|
12
12
|
|
13
|
-
def
|
14
|
-
|
13
|
+
def initialize(info, superclass: nil)
|
14
|
+
@superclass = superclass
|
15
|
+
super info
|
15
16
|
end
|
16
17
|
|
17
18
|
def superclass
|
18
|
-
|
19
|
-
|
19
|
+
@superclass ||= if info.gtype_struct?
|
20
|
+
gtype_struct_parent
|
21
|
+
elsif GObject.type_fundamental(info.gtype) == GObject::TYPE_BOXED
|
22
|
+
BoxedBase
|
23
|
+
else
|
24
|
+
StructBase
|
25
|
+
end
|
26
|
+
end
|
20
27
|
|
21
|
-
|
28
|
+
private
|
29
|
+
|
30
|
+
def layout_superclass
|
31
|
+
GirFFI::Struct
|
22
32
|
end
|
23
33
|
|
24
34
|
def klass
|
25
35
|
@klass ||= get_or_define_class(namespace_module, @classname) { superclass }
|
26
36
|
end
|
27
37
|
|
38
|
+
def parent_info
|
39
|
+
@parent_info ||= parent_field_type&.interface
|
40
|
+
end
|
41
|
+
|
28
42
|
def parent_field_type
|
29
|
-
fields.first
|
43
|
+
fields.first&.field_type
|
44
|
+
end
|
45
|
+
|
46
|
+
def gtype_struct_parent
|
47
|
+
full_name = info.full_type_name
|
48
|
+
if full_name == "GObject::InitiallyUnownedClass"
|
49
|
+
GObject::ObjectClass
|
50
|
+
else
|
51
|
+
raise "Unable to calculate parent class for #{full_name}" unless parent_info
|
52
|
+
|
53
|
+
Builder.build_class parent_info
|
54
|
+
end
|
30
55
|
end
|
31
56
|
end
|
32
57
|
end
|
data/lib/gir_ffi/core.rb
CHANGED
@@ -42,7 +42,7 @@ module GirFFI
|
|
42
42
|
|
43
43
|
if block_given?
|
44
44
|
warn "Using define_type with a block is deprecated." \
|
45
|
-
|
45
|
+
" Call the relevant functions inside the class definition instead."
|
46
46
|
yield info
|
47
47
|
end
|
48
48
|
Builders::UserDefinedBuilder.new(info).build_class
|
data/lib/gir_ffi/in_pointer.rb
CHANGED
@@ -77,9 +77,10 @@ module GirFFI
|
|
77
77
|
def from_module_type_array(type, ary)
|
78
78
|
if type == GObject::Value
|
79
79
|
from_gvalue_array type, ary
|
80
|
-
elsif type < GirFFI::ClassBase
|
80
|
+
elsif type < GirFFI::ClassBase ||
|
81
|
+
type.singleton_class < GirFFI::InterfaceBase
|
81
82
|
from_struct_array type, ary
|
82
|
-
elsif type.singleton_class
|
83
|
+
elsif type.singleton_class < GirFFI::EnumBase
|
83
84
|
from_enum_array type, ary
|
84
85
|
else
|
85
86
|
raise NotImplementedError, type
|
@@ -166,7 +166,8 @@ module GirFFI
|
|
166
166
|
end
|
167
167
|
|
168
168
|
def needs_c_to_ruby_conversion_for_closures?
|
169
|
-
[:array, :c, :error, :ghash, :glist, :struct, :strv]
|
169
|
+
[:array, :c, :error, :ghash, :glist, :ptr_array, :struct, :strv]
|
170
|
+
.include?(flattened_tag)
|
170
171
|
end
|
171
172
|
|
172
173
|
def needs_ruby_to_c_conversion_for_closures?
|
@@ -18,6 +18,11 @@ module GirFFI
|
|
18
18
|
send method_name, *arguments, &block
|
19
19
|
end
|
20
20
|
|
21
|
+
# TODO: Unify with implementation in ObjectBase
|
22
|
+
def copy_value_to_pointer(value, pointer, offset = 0)
|
23
|
+
pointer.put_pointer offset, value.to_ptr
|
24
|
+
end
|
25
|
+
|
21
26
|
def wrap(ptr)
|
22
27
|
ptr.to_object
|
23
28
|
end
|
data/lib/gir_ffi/type_map.rb
CHANGED
data/lib/gir_ffi/version.rb
CHANGED
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matijs van Zuijlen
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-20 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:
|
47
|
+
version: 2.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:
|
54
|
+
version: 2.0.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: minitest
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '5.12'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest-focus
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.3.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.3.1
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rake
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +100,14 @@ dependencies:
|
|
86
100
|
requirements:
|
87
101
|
- - "~>"
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
103
|
+
version: 0.2.0
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
110
|
+
version: 0.2.0
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rexml
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,28 +142,28 @@ dependencies:
|
|
128
142
|
requirements:
|
129
143
|
- - "~>"
|
130
144
|
- !ruby/object:Gem::Version
|
131
|
-
version: 1.
|
145
|
+
version: 1.23.0
|
132
146
|
type: :development
|
133
147
|
prerelease: false
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
150
|
- - "~>"
|
137
151
|
- !ruby/object:Gem::Version
|
138
|
-
version: 1.
|
152
|
+
version: 1.23.0
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: rubocop-minitest
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
142
156
|
requirements:
|
143
157
|
- - "~>"
|
144
158
|
- !ruby/object:Gem::Version
|
145
|
-
version: 0.
|
159
|
+
version: 0.16.0
|
146
160
|
type: :development
|
147
161
|
prerelease: false
|
148
162
|
version_requirements: !ruby/object:Gem::Requirement
|
149
163
|
requirements:
|
150
164
|
- - "~>"
|
151
165
|
- !ruby/object:Gem::Version
|
152
|
-
version: 0.
|
166
|
+
version: 0.16.0
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: rubocop-packaging
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,28 +184,28 @@ dependencies:
|
|
170
184
|
requirements:
|
171
185
|
- - "~>"
|
172
186
|
- !ruby/object:Gem::Version
|
173
|
-
version: 1.
|
187
|
+
version: 1.12.0
|
174
188
|
type: :development
|
175
189
|
prerelease: false
|
176
190
|
version_requirements: !ruby/object:Gem::Requirement
|
177
191
|
requirements:
|
178
192
|
- - "~>"
|
179
193
|
- !ruby/object:Gem::Version
|
180
|
-
version: 1.
|
194
|
+
version: 1.12.0
|
181
195
|
- !ruby/object:Gem::Dependency
|
182
196
|
name: simplecov
|
183
197
|
requirement: !ruby/object:Gem::Requirement
|
184
198
|
requirements:
|
185
199
|
- - "~>"
|
186
200
|
- !ruby/object:Gem::Version
|
187
|
-
version: 0.
|
201
|
+
version: 0.21.0
|
188
202
|
type: :development
|
189
203
|
prerelease: false
|
190
204
|
version_requirements: !ruby/object:Gem::Requirement
|
191
205
|
requirements:
|
192
206
|
- - "~>"
|
193
207
|
- !ruby/object:Gem::Version
|
194
|
-
version: 0.
|
208
|
+
version: 0.21.0
|
195
209
|
description: |
|
196
210
|
GirFFI creates bindings for GObject-based libraries at runtime based on introspection
|
197
211
|
data provided by the GObject Introspection Repository (GIR) system. Bindings are created
|
@@ -286,7 +300,6 @@ files:
|
|
286
300
|
- lib/gir_ffi/builders/callback_argument_builder.rb
|
287
301
|
- lib/gir_ffi/builders/callback_builder.rb
|
288
302
|
- lib/gir_ffi/builders/callback_return_value_builder.rb
|
289
|
-
- lib/gir_ffi/builders/class_struct_builder.rb
|
290
303
|
- lib/gir_ffi/builders/closure_argument_builder.rb
|
291
304
|
- lib/gir_ffi/builders/closure_convertor.rb
|
292
305
|
- lib/gir_ffi/builders/closure_return_value_builder.rb
|
@@ -397,7 +410,8 @@ metadata:
|
|
397
410
|
homepage_uri: http://www.github.com/mvz/ruby-gir-ffi
|
398
411
|
source_code_uri: https://github.com/mvz/gir_ffi
|
399
412
|
changelog_uri: https://github.com/mvz/gir_ffi/blob/master/Changelog.md
|
400
|
-
|
413
|
+
rubygems_mfa_required: 'true'
|
414
|
+
post_install_message:
|
401
415
|
rdoc_options:
|
402
416
|
- "--main"
|
403
417
|
- README.md
|
@@ -407,15 +421,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
407
421
|
requirements:
|
408
422
|
- - ">="
|
409
423
|
- !ruby/object:Gem::Version
|
410
|
-
version: 2.
|
424
|
+
version: 2.6.0
|
411
425
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
412
426
|
requirements:
|
413
427
|
- - ">="
|
414
428
|
- !ruby/object:Gem::Version
|
415
429
|
version: '0'
|
416
430
|
requirements: []
|
417
|
-
rubygems_version: 3.
|
418
|
-
signing_key:
|
431
|
+
rubygems_version: 3.2.22
|
432
|
+
signing_key:
|
419
433
|
specification_version: 4
|
420
434
|
summary: FFI-based GObject binding using the GObject Introspection Repository
|
421
435
|
test_files: []
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "gir_ffi/builders/struct_builder"
|
4
|
-
|
5
|
-
module GirFFI
|
6
|
-
module Builders
|
7
|
-
# Implements the creation of a class representing a Struct.
|
8
|
-
class ClassStructBuilder < RegisteredTypeBuilder
|
9
|
-
include StructLike
|
10
|
-
|
11
|
-
attr_reader :superclass
|
12
|
-
|
13
|
-
def initialize(info, super_class_struct)
|
14
|
-
@superclass = super_class_struct
|
15
|
-
super info
|
16
|
-
raise "Info does not represent gtype_struct" unless info.gtype_struct?
|
17
|
-
end
|
18
|
-
|
19
|
-
def layout_superclass
|
20
|
-
GirFFI::Struct
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|