gir_ffi 0.15.7 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Changelog.md +44 -18
- data/README.md +8 -23
- data/lib/ffi-glib/bytes.rb +0 -12
- data/lib/ffi-glib/hash_table.rb +1 -1
- data/lib/ffi-glib/main_loop.rb +1 -1
- data/lib/ffi-glib/ptr_array.rb +24 -15
- data/lib/ffi-glib/variant.rb +4 -6
- data/lib/ffi-gobject/object.rb +30 -60
- data/lib/ffi-gobject/object_class.rb +2 -10
- data/lib/ffi-gobject/value.rb +26 -26
- data/lib/ffi-gobject.rb +4 -18
- data/lib/ffi-gobject_introspection/i_base_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_constant_info.rb +10 -10
- data/lib/ffi-gobject_introspection/lib.rb +11 -11
- data/lib/ffi-gobject_introspection.rb +19 -19
- data/lib/gir_ffi/builder.rb +1 -1
- data/lib/gir_ffi/builders/argument_builder_collection.rb +24 -8
- data/lib/gir_ffi/builders/base_argument_builder.rb +2 -2
- data/lib/gir_ffi/builders/base_method_builder.rb +23 -23
- data/lib/gir_ffi/builders/constructor_builder.rb +1 -1
- data/lib/gir_ffi/builders/mapping_method_builder.rb +1 -1
- data/lib/gir_ffi/builders/marshalling_method_builder.rb +2 -2
- data/lib/gir_ffi/builders/module_builder.rb +1 -1
- data/lib/gir_ffi/builders/object_builder.rb +10 -12
- data/lib/gir_ffi/builders/struct_builder.rb +1 -1
- data/lib/gir_ffi/builders/type_builder.rb +9 -9
- data/lib/gir_ffi/builders/user_defined_builder.rb +24 -26
- data/lib/gir_ffi/class_base.rb +1 -3
- data/lib/gir_ffi/core.rb +0 -5
- data/lib/gir_ffi/in_pointer.rb +6 -6
- data/lib/gir_ffi/info_ext/full_type_name.rb +3 -2
- data/lib/gir_ffi/info_ext/i_function_info.rb +10 -0
- data/lib/gir_ffi/info_ext/i_signal_info.rb +8 -6
- data/lib/gir_ffi/info_ext/i_type_info.rb +21 -26
- data/lib/gir_ffi/info_ext/i_vfunc_info.rb +4 -0
- data/lib/gir_ffi/instance_method_setup.rb +3 -1
- data/lib/gir_ffi/object_base.rb +5 -5
- data/lib/gir_ffi/struct_like_base.rb +0 -1
- data/lib/gir_ffi/type_map.rb +30 -30
- data/lib/gir_ffi/unintrospectable_type_info.rb +2 -2
- data/lib/gir_ffi/user_defined_object_info.rb +0 -3
- data/lib/gir_ffi/user_defined_property_info.rb +33 -33
- data/lib/gir_ffi/version.rb +1 -1
- data/lib/gir_ffi/zero_terminated.rb +1 -1
- data/lib/gir_ffi-base/gobject.rb +1 -1
- metadata +33 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfd3130c297141938f61b59a4e4be4ec2e76832cf38341533f18a5598ac6cd30
|
4
|
+
data.tar.gz: 2e94de2c70d365baa1fc1fd506e5cadbaf5d3b9aaa36dbde69e7813f742ce357
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94de6fa54920e6c878d271f57c9c737aa5b6ca6025fe5d1d395e26e146208e8dafb9c43dc679984dcaa4216d373f658f25e8cdd676f96724cd7d8cbf7aae6012
|
7
|
+
data.tar.gz: d4f06ba95a49d8ad6476cda459dc93d3630533b9dc48f1fc48917c86d7124965700771a71084925f5382836352fe9b203536c0df686fb2a554530fb27e203cbb
|
data/Changelog.md
CHANGED
@@ -1,5 +1,30 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.16.0 / 2022-05-21
|
4
|
+
|
5
|
+
* Support Ruby 3.1
|
6
|
+
* Rename `#object_class` to `#class_struct`
|
7
|
+
* Remove `GObject.object_class_from_instance`
|
8
|
+
* Limit public interface of `BaseMethodBuilder`
|
9
|
+
* Remove deprecated methods from `GObject::Object`
|
10
|
+
* Stop accepting blocks when defining a type
|
11
|
+
* Check parameter direction in signal argument conversion
|
12
|
+
* Drop support for JRuby
|
13
|
+
* Drop support for Ruby 2.6
|
14
|
+
|
15
|
+
## 0.15.9 / 2021-12-05
|
16
|
+
|
17
|
+
* Skip setting destroy notifier state if types don't make sense
|
18
|
+
* Handle functions with multiple user-supplied callback arguments
|
19
|
+
|
20
|
+
## 0.15.8 / 2021-11-20
|
21
|
+
|
22
|
+
* Drop support for Ruby 2.5
|
23
|
+
* Bump minimum supported version of gobject-introspection to 1.56.0
|
24
|
+
* Bump minimum supported version of glib to 2.56.0
|
25
|
+
* Handle functions that have swapped closure annotation
|
26
|
+
* Handle GPtrArray arguments in signal handlers
|
27
|
+
|
3
28
|
## 0.15.7 / 2021-01-15
|
4
29
|
|
5
30
|
* Handle sized arrays with interface element types
|
@@ -131,8 +156,8 @@
|
|
131
156
|
changed.
|
132
157
|
* Make `Strv#each` thread-safe.
|
133
158
|
* Drop support for CRuby 2.0.
|
134
|
-
* Move `::type_init` and base `Strv` implementation into `GObjectIntrospection`,
|
135
|
-
it stand-alone.
|
159
|
+
* Move `::type_init` and base `Strv` implementation into `GObjectIntrospection`,
|
160
|
+
making it stand-alone.
|
136
161
|
* Move `GLib::Boolean` to `GirFFI::Boolean`.
|
137
162
|
* Guard against instantiating abstract classes using the default constructor.
|
138
163
|
* Handle user-defined properties containing dashes
|
@@ -153,7 +178,7 @@
|
|
153
178
|
actual effect even on CRuby.
|
154
179
|
- Immediately free string pointers whose ownership is transfered. Again, the
|
155
180
|
#autorelease technique doesn't work on JRuby.
|
156
|
-
- Fix handling of callee-allocated out parameters in vfuncs. The put_pointer
|
181
|
+
- Fix handling of callee-allocated out parameters in vfuncs. The `put_pointer`
|
157
182
|
method was wrongly called, and JRuby is more picky about what types that
|
158
183
|
method expects, exposing the bug.
|
159
184
|
|
@@ -172,7 +197,8 @@
|
|
172
197
|
|
173
198
|
## 0.9.5 / 2016-03-05
|
174
199
|
|
175
|
-
* Abort if modules were defined earlier, e.g., through the gems from the
|
200
|
+
* Abort if modules were defined earlier, e.g., through the gems from the
|
201
|
+
ruby-gnome family.
|
176
202
|
* Extend integration testing with GObjectIntrospection's test libraries.
|
177
203
|
* Find signals on user-defined types.
|
178
204
|
* Allow getting and setting of properties with a callback value.
|
@@ -487,7 +513,7 @@
|
|
487
513
|
## 0.4.2 / 2012-09-22
|
488
514
|
|
489
515
|
* Make objects and interfaces wrap poiners in the class that matches
|
490
|
-
their GType.
|
516
|
+
their GType.
|
491
517
|
|
492
518
|
## 0.4.1 / 2012-09-18
|
493
519
|
|
@@ -503,7 +529,7 @@ their GType.
|
|
503
529
|
## 0.3.2 / 2012-08-24
|
504
530
|
|
505
531
|
* Correctly set FFI return type when callbacks that return GObjects have
|
506
|
-
incomplete type specification.
|
532
|
+
incomplete type specification.
|
507
533
|
|
508
534
|
## 0.3.1 / 2012-05-13
|
509
535
|
|
@@ -531,15 +557,15 @@ incomplete type specification.
|
|
531
557
|
|
532
558
|
## 0.2.2 / 2011-12-07
|
533
559
|
|
534
|
-
* Fix issue #19: Check if a GLib::PtrArray.add method was generated
|
535
|
-
|
560
|
+
* Fix issue #19: Check if a GLib::PtrArray.add method was generated before
|
561
|
+
attempting to remove it.
|
536
562
|
* Fix two issues with pretty printing that made output for GLib have syntax
|
537
|
-
errors.
|
563
|
+
errors.
|
538
564
|
|
539
565
|
## 0.2.1 / 2011-11-20
|
540
566
|
|
541
|
-
* Fix handling of output parameters that are arrays of pointers to
|
542
|
-
|
567
|
+
* Fix handling of output parameters that are arrays of pointers to structures
|
568
|
+
(i.e., of type `Foo***`).
|
543
569
|
|
544
570
|
## 0.2.0 / 2011-11-19
|
545
571
|
|
@@ -549,9 +575,9 @@ structures (i.e., of type `Foo***`).
|
|
549
575
|
- Get rid of `#[]` and `#[]=`.
|
550
576
|
* Explicitely load `libgirepository` with ABI version 1.
|
551
577
|
* Improve implementation of GLib container classes (GList etc.):
|
552
|
-
- Real constructors.
|
553
|
-
- `#append` and friends are instance methods now.
|
554
|
-
- Conversion methods to cast Ruby containers to GLib containers.
|
578
|
+
- Real constructors.
|
579
|
+
- `#append` and friends are instance methods now.
|
580
|
+
- Conversion methods to cast Ruby containers to GLib containers.
|
555
581
|
* Start implementing pretty printing.
|
556
582
|
* Various refactorings.
|
557
583
|
|
@@ -564,10 +590,10 @@ structures (i.e., of type `Foo***`).
|
|
564
590
|
## 0.0.14 / 2011-10-28
|
565
591
|
|
566
592
|
* Support GObject Introspection version 1.30:
|
567
|
-
- Add support for layouts with fixed-length arrays.
|
568
|
-
- Handle type names starting with underscores.
|
569
|
-
- Call `g_signal_emitv` directly to avoid conflict in introspection info
|
570
|
-
|
593
|
+
- Add support for layouts with fixed-length arrays.
|
594
|
+
- Handle type names starting with underscores.
|
595
|
+
- Call `g_signal_emitv` directly to avoid conflict in introspection info
|
596
|
+
with earlier versions of GObject Introspection.
|
571
597
|
|
572
598
|
## 0.0.13 / 2011-09-09
|
573
599
|
|
data/README.md
CHANGED
@@ -9,10 +9,9 @@ Ruby bindings for GNOME using the GObject Introspection Repository.
|
|
9
9
|
## Status
|
10
10
|
|
11
11
|
[](http://badge.fury.io/rb/gir_ffi)
|
12
|
-
[](https://travis-ci.org/mvz/gir_ffi)
|
12
|
+
[](https://github.com/mvz/gir_ffi/actions/workflows/ruby.yml)
|
14
13
|
[](https://codeclimate.com/github/mvz/gir_ffi)
|
15
|
-
[](https://inch-ci.org/github/mvz/gir_ffi
|
14
|
+
[](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, 3.0 and 3.1.
|
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/bytes.rb
CHANGED
@@ -7,18 +7,6 @@ module GLib
|
|
7
7
|
class Bytes
|
8
8
|
include Enumerable
|
9
9
|
|
10
|
-
remove_method :get_data if method_defined? :get_data
|
11
|
-
|
12
|
-
# @override
|
13
|
-
# NOTE: Needed due to mis-identification of the element-type of the
|
14
|
-
# resulting sized array for the default binding.
|
15
|
-
def get_data
|
16
|
-
length_ptr = FFI::MemoryPointer.new :size_t
|
17
|
-
data_ptr = Lib.g_bytes_get_data self, length_ptr
|
18
|
-
length = length_ptr.get_size_t(0)
|
19
|
-
GirFFI::SizedArray.wrap(:guint8, length, data_ptr)
|
20
|
-
end
|
21
|
-
|
22
10
|
def each(&block)
|
23
11
|
data.each(&block)
|
24
12
|
end
|
data/lib/ffi-glib/hash_table.rb
CHANGED
data/lib/ffi-glib/main_loop.rb
CHANGED
@@ -40,7 +40,7 @@ module GLib
|
|
40
40
|
setup_instance_method! :run
|
41
41
|
|
42
42
|
def run_with_thread_enabler
|
43
|
-
ThreadEnabler.instance.setup_idle_handler
|
43
|
+
ThreadEnabler.instance.setup_idle_handler
|
44
44
|
RUNNING_LOOPS << self
|
45
45
|
result = run_without_thread_enabler
|
46
46
|
exception = EXCEPTIONS.shift
|
data/lib/ffi-glib/ptr_array.rb
CHANGED
@@ -50,21 +50,7 @@ module GLib
|
|
50
50
|
|
51
51
|
# Re-implementation of the g_ptrarray_index macro
|
52
52
|
def index(idx)
|
53
|
-
|
54
|
-
raise IndexError, "Index #{idx} outside of bounds 0..#{length - 1}"
|
55
|
-
end
|
56
|
-
|
57
|
-
item_ptr = data_ptr + idx * element_size
|
58
|
-
|
59
|
-
convert_element_type = case element_type
|
60
|
-
when :utf8
|
61
|
-
:utf8
|
62
|
-
when GirFFI::ObjectBase
|
63
|
-
element_type
|
64
|
-
else
|
65
|
-
[:pointer, element_type]
|
66
|
-
end
|
67
|
-
|
53
|
+
item_ptr = item_pointer(idx)
|
68
54
|
convertor = GirFFI::ArrayElementConvertor.new convert_element_type, item_ptr
|
69
55
|
convertor.to_ruby_value
|
70
56
|
end
|
@@ -85,6 +71,29 @@ module GLib
|
|
85
71
|
|
86
72
|
private
|
87
73
|
|
74
|
+
def item_pointer(idx)
|
75
|
+
check_bounds(idx)
|
76
|
+
|
77
|
+
data_ptr + idx * element_size
|
78
|
+
end
|
79
|
+
|
80
|
+
def check_bounds(idx)
|
81
|
+
unless (0...length).cover? idx
|
82
|
+
raise IndexError, "Index #{idx} outside of bounds 0..#{length - 1}"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def convert_element_type
|
87
|
+
case element_type
|
88
|
+
when :utf8
|
89
|
+
:utf8
|
90
|
+
when GirFFI::ObjectBase
|
91
|
+
element_type
|
92
|
+
else
|
93
|
+
[:pointer, element_type]
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
88
97
|
def element_size
|
89
98
|
POINTER_SIZE
|
90
99
|
end
|
data/lib/ffi-glib/variant.rb
CHANGED
@@ -14,13 +14,11 @@ module GLib
|
|
14
14
|
alias get_string_without_override get_string
|
15
15
|
alias get_string get_string_with_override
|
16
16
|
|
17
|
-
# Initializing method used in constructors. For Variant
|
18
|
-
#
|
19
|
-
#
|
20
|
-
# NOTE: This is very hard to test since it is not possible to get the
|
21
|
-
# variant's ref count directely. However, there is an error when running
|
22
|
-
# the tests on 32-bit systems.
|
17
|
+
# Initializing method used in constructors. For Variant the constructing
|
18
|
+
# functions all return floating references, so this is need to take full
|
19
|
+
# ownership.
|
23
20
|
#
|
21
|
+
# Also see the documentation for g_variant_ref_sink.
|
24
22
|
def store_pointer(ptr)
|
25
23
|
Lib.g_variant_ref_sink ptr
|
26
24
|
super
|
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
|
-
gparam.name = name
|
20
|
-
gparam.value = value
|
21
|
-
end
|
22
|
-
end
|
23
|
-
initialize_without_automatic_gtype(self.class.gtype, gparameters)
|
24
|
-
end
|
25
|
-
|
26
|
-
alias initialize_without_automatic_gtype initialize
|
27
|
-
alias initialize initialize_with_automatic_gtype
|
28
|
-
else
|
29
|
-
GObject::Lib.attach_function(:g_object_new_with_properties,
|
30
|
-
[:size_t, :uint32, :pointer, :pointer],
|
31
|
-
:pointer)
|
32
|
-
|
33
|
-
def self.new_with_properties(*args, &block)
|
34
|
-
obj = allocate
|
35
|
-
obj.__send__ :initialize_with_properties, *args, &block
|
36
|
-
obj
|
37
|
-
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
|
38
19
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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)
|
43
24
|
|
44
|
-
|
45
|
-
|
46
|
-
|
25
|
+
n_properties = names.length
|
26
|
+
names_arr = GirFFI::SizedArray.from(:utf8, -1, names)
|
27
|
+
gvalues_arr = GirFFI::SizedArray.from(GObject::Value, -1, gvalues)
|
47
28
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
54
35
|
|
55
|
-
|
56
|
-
|
57
|
-
|
36
|
+
alias old_initialze initialize
|
37
|
+
alias initialize initialize_with_properties
|
38
|
+
remove_method :old_initialze
|
58
39
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
end
|
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
|
@@ -137,17 +117,12 @@ module GObject
|
|
137
117
|
end
|
138
118
|
|
139
119
|
def property_param_spec(property_name)
|
140
|
-
|
120
|
+
class_struct.find_property property_name or
|
141
121
|
raise GirFFI::PropertyNotFoundError.new(property_name, self.class)
|
142
122
|
end
|
143
123
|
|
144
124
|
# Overrides for GObject, GObject's generic base class.
|
145
125
|
module Overrides
|
146
|
-
# @deprecated
|
147
|
-
def get_property_extended(property_name)
|
148
|
-
get_property(property_name)
|
149
|
-
end
|
150
|
-
|
151
126
|
def get_property(property_name)
|
152
127
|
gvalue = gvalue_for_property property_name
|
153
128
|
super property_name, gvalue
|
@@ -159,11 +134,6 @@ module GObject
|
|
159
134
|
value
|
160
135
|
end
|
161
136
|
|
162
|
-
# @deprecated
|
163
|
-
def set_property_extended(property_name, value)
|
164
|
-
set_property property_name, value
|
165
|
-
end
|
166
|
-
|
167
137
|
def set_property(property_name, value)
|
168
138
|
type_info = get_property_type property_name
|
169
139
|
value = property_value_pre_conversion(value, type_info) if type_info
|
@@ -1,18 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
GObject::Object.
|
3
|
+
GObject::Object.class_struct
|
4
4
|
|
5
5
|
module GObject
|
6
|
-
# Overrides for GObjectClass,
|
6
|
+
# Overrides for GObjectClass, the class struct for GObject::Object
|
7
7
|
class ObjectClass
|
8
|
-
def set_property=(callback)
|
9
|
-
struct[:set_property] = GObject::ObjectSetPropertyFunc.from callback
|
10
|
-
end
|
11
|
-
|
12
|
-
def get_property=(callback)
|
13
|
-
struct[:get_property] = GObject::ObjectGetPropertyFunc.from callback
|
14
|
-
end
|
15
|
-
|
16
8
|
def gtype
|
17
9
|
to_ptr.get_gtype 0
|
18
10
|
end
|
data/lib/ffi-gobject/value.rb
CHANGED
@@ -8,29 +8,29 @@ module GObject
|
|
8
8
|
setup_instance_method! :init
|
9
9
|
|
10
10
|
METHOD_MAP = {
|
11
|
-
TYPE_INVALID
|
11
|
+
TYPE_INVALID => [:get_none, :set_none],
|
12
12
|
# TYPE_NONE is skipped
|
13
|
-
TYPE_INTERFACE => [:get_object,
|
14
|
-
TYPE_CHAR
|
15
|
-
TYPE_UCHAR
|
16
|
-
TYPE_BOOLEAN
|
17
|
-
TYPE_INT
|
18
|
-
TYPE_UINT
|
19
|
-
TYPE_LONG
|
20
|
-
TYPE_ULONG
|
21
|
-
TYPE_INT64
|
22
|
-
TYPE_UINT64
|
23
|
-
TYPE_ENUM
|
24
|
-
TYPE_FLAGS
|
25
|
-
TYPE_FLOAT
|
26
|
-
TYPE_DOUBLE
|
27
|
-
TYPE_STRING
|
28
|
-
TYPE_POINTER
|
29
|
-
TYPE_BOXED
|
30
|
-
TYPE_PARAM
|
31
|
-
TYPE_OBJECT
|
32
|
-
TYPE_GTYPE
|
33
|
-
TYPE_VARIANT
|
13
|
+
TYPE_INTERFACE => [:get_object, :set_instance_enhanced],
|
14
|
+
TYPE_CHAR => [:get_schar, :set_schar],
|
15
|
+
TYPE_UCHAR => [:get_uchar, :set_uchar],
|
16
|
+
TYPE_BOOLEAN => [:get_boolean, :set_boolean],
|
17
|
+
TYPE_INT => [:get_int, :set_int],
|
18
|
+
TYPE_UINT => [:get_uint, :set_uint],
|
19
|
+
TYPE_LONG => [:get_long, :set_long],
|
20
|
+
TYPE_ULONG => [:get_ulong, :set_ulong],
|
21
|
+
TYPE_INT64 => [:get_int64, :set_int64],
|
22
|
+
TYPE_UINT64 => [:get_uint64, :set_uint64],
|
23
|
+
TYPE_ENUM => [:get_enum_enhanced, :set_enum_enhanced],
|
24
|
+
TYPE_FLAGS => [:get_flags_enhanced, :set_flags_enhanced],
|
25
|
+
TYPE_FLOAT => [:get_float, :set_float],
|
26
|
+
TYPE_DOUBLE => [:get_double, :set_double],
|
27
|
+
TYPE_STRING => [:get_string, :set_string],
|
28
|
+
TYPE_POINTER => [:get_pointer, :set_pointer],
|
29
|
+
TYPE_BOXED => [:get_boxed, :set_boxed],
|
30
|
+
TYPE_PARAM => [:get_param, :set_param],
|
31
|
+
TYPE_OBJECT => [:get_object, :set_instance_enhanced],
|
32
|
+
TYPE_GTYPE => [:get_gtype, :set_gtype],
|
33
|
+
TYPE_VARIANT => [:get_variant, :set_variant]
|
34
34
|
}.freeze
|
35
35
|
|
36
36
|
# TODO: Give more generic name
|
@@ -68,11 +68,11 @@ module GObject
|
|
68
68
|
end
|
69
69
|
|
70
70
|
CLASS_TO_GTYPE_MAP = {
|
71
|
-
NilClass
|
72
|
-
TrueClass
|
71
|
+
NilClass => TYPE_INVALID,
|
72
|
+
TrueClass => TYPE_BOOLEAN,
|
73
73
|
FalseClass => TYPE_BOOLEAN,
|
74
|
-
Integer
|
75
|
-
String
|
74
|
+
Integer => TYPE_INT,
|
75
|
+
String => TYPE_STRING
|
76
76
|
}.freeze
|
77
77
|
|
78
78
|
# Overrides for existing Value methods
|
data/lib/ffi-gobject.rb
CHANGED
@@ -31,17 +31,6 @@ module GObject
|
|
31
31
|
type_name type_from_instance instance
|
32
32
|
end
|
33
33
|
|
34
|
-
def self.object_class_from_instance(instance)
|
35
|
-
object_class_from_instance_pointer instance.to_ptr
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.object_class_from_instance_pointer(inst_ptr)
|
39
|
-
return nil if inst_ptr.null?
|
40
|
-
|
41
|
-
klsptr = inst_ptr.get_pointer 0
|
42
|
-
ObjectClass.wrap klsptr
|
43
|
-
end
|
44
|
-
|
45
34
|
def self.signal_lookup_from_instance(signal, object)
|
46
35
|
signal_lookup signal, type_from_instance(object)
|
47
36
|
end
|
@@ -55,11 +44,7 @@ module GObject
|
|
55
44
|
argument_gvalues = sig_info.arguments_to_gvalues object, args
|
56
45
|
return_gvalue = sig_info.gvalue_for_return_value
|
57
46
|
|
58
|
-
|
59
|
-
# NOTE: Depending on the version of GObjectIntrospection, the result will
|
60
|
-
# be stored in result or return_gvalue. This was changed between versions
|
61
|
-
# 1.44 and 1.46.
|
62
|
-
result || return_gvalue.get_value
|
47
|
+
signal_emitv argument_gvalues, signal_id, detail_quark, return_gvalue
|
63
48
|
end
|
64
49
|
|
65
50
|
def self.signal_connect(object, detailed_signal, data = nil, after = false, &block)
|
@@ -69,7 +54,7 @@ module GObject
|
|
69
54
|
sig_info = object.class.find_signal signal_name
|
70
55
|
|
71
56
|
closure = sig_info.wrap_in_closure do |*args|
|
72
|
-
|
57
|
+
yield(*args << data)
|
73
58
|
end
|
74
59
|
|
75
60
|
signal_connect_closure object, detailed_signal, closure, after
|
@@ -85,7 +70,8 @@ module GObject
|
|
85
70
|
load_class :ClosureMarshal
|
86
71
|
load_class :ParamFlags
|
87
72
|
|
88
|
-
#
|
73
|
+
# Attach some needed functions to the GObject Lib, which was set up in
|
74
|
+
# `gir_ffi-base/gobject/lib.rb`.
|
89
75
|
Lib.class_eval do
|
90
76
|
attach_function :g_object_ref_sink, [:pointer], :pointer
|
91
77
|
attach_function :g_object_ref, [:pointer], :pointer
|
@@ -49,7 +49,7 @@ module GObjectIntrospection
|
|
49
49
|
method = method.to_s
|
50
50
|
cache_ivar = "@#{method}_cache"
|
51
51
|
single ||= method[0..-2]
|
52
|
-
count = method.sub(/^(get_)?/,
|
52
|
+
count = method.sub(/^(get_)?/, "\\1n_")
|
53
53
|
class_eval <<-CODE, __FILE__, __LINE__ + 1
|
54
54
|
def #{method} # def fields
|
55
55
|
#{cache_ivar} ||= # @fields_cache ||=
|
@@ -5,16 +5,16 @@ module GObjectIntrospection
|
|
5
5
|
class IConstantInfo < IBaseInfo
|
6
6
|
TYPE_TAG_TO_UNION_MEMBER = {
|
7
7
|
gboolean: :v_boolean,
|
8
|
-
gint8:
|
9
|
-
gint16:
|
10
|
-
gint32:
|
11
|
-
gint64:
|
12
|
-
guint8:
|
13
|
-
guint16:
|
14
|
-
guint32:
|
15
|
-
guint64:
|
16
|
-
gdouble:
|
17
|
-
utf8:
|
8
|
+
gint8: :v_int8,
|
9
|
+
gint16: :v_int16,
|
10
|
+
gint32: :v_int32,
|
11
|
+
gint64: :v_int64,
|
12
|
+
guint8: :v_uint8,
|
13
|
+
guint16: :v_uint16,
|
14
|
+
guint32: :v_uint32,
|
15
|
+
guint64: :v_uint64,
|
16
|
+
gdouble: :v_double,
|
17
|
+
utf8: :v_string
|
18
18
|
}.freeze
|
19
19
|
|
20
20
|
def value
|
@@ -63,12 +63,12 @@ module GObjectIntrospection
|
|
63
63
|
|
64
64
|
# IFunctionInfo
|
65
65
|
bit_mask :IFunctionInfoFlags,
|
66
|
-
is_method:
|
66
|
+
is_method: (1 << 0),
|
67
67
|
is_constructor: (1 << 1),
|
68
|
-
is_getter:
|
69
|
-
is_setter:
|
70
|
-
wraps_vfunc:
|
71
|
-
throws:
|
68
|
+
is_getter: (1 << 2),
|
69
|
+
is_setter: (1 << 3),
|
70
|
+
wraps_vfunc: (1 << 4),
|
71
|
+
throws: (1 << 5)
|
72
72
|
|
73
73
|
attach_function :g_function_info_get_symbol, [:pointer], :string
|
74
74
|
attach_function :g_function_info_get_flags, [:pointer], :IFunctionInfoFlags
|
@@ -231,10 +231,10 @@ module GObjectIntrospection
|
|
231
231
|
|
232
232
|
# IVFuncInfo
|
233
233
|
bit_mask :IVFuncInfoFlags,
|
234
|
-
must_chain_up:
|
235
|
-
must_override:
|
234
|
+
must_chain_up: (1 << 0),
|
235
|
+
must_override: (1 << 1),
|
236
236
|
must_not_override: (1 << 2),
|
237
|
-
throws:
|
237
|
+
throws: (1 << 3)
|
238
238
|
|
239
239
|
attach_function :g_vfunc_info_get_flags, [:pointer], :IVFuncInfoFlags
|
240
240
|
attach_function :g_vfunc_info_get_invoker, [:pointer], :pointer
|
@@ -294,9 +294,9 @@ module GObjectIntrospection
|
|
294
294
|
|
295
295
|
# NOTE: This type has more values, but these are the ones used
|
296
296
|
bit_mask :ParamFlags,
|
297
|
-
readable:
|
298
|
-
writable:
|
299
|
-
construct:
|
297
|
+
readable: (1 << 0),
|
298
|
+
writable: (1 << 1),
|
299
|
+
construct: (1 << 2),
|
300
300
|
construct_only: (1 << 3)
|
301
301
|
|
302
302
|
attach_function :g_property_info_get_flags, [:pointer], :ParamFlags
|