gir_ffi 0.10.2 → 0.11.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 +13 -0
- data/Gemfile +9 -4
- data/README.md +3 -2
- data/Rakefile +2 -1
- data/lib/ffi-glib/byte_array.rb +1 -1
- data/lib/ffi-glib/main_loop.rb +2 -1
- data/lib/ffi-glib/strv.rb +5 -2
- data/lib/ffi-glib/variant.rb +3 -5
- data/lib/ffi-glib.rb +4 -0
- data/lib/ffi-gobject/closure.rb +8 -10
- data/lib/ffi-gobject/object.rb +9 -6
- data/lib/ffi-gobject/param_spec.rb +4 -0
- data/lib/ffi-gobject/value.rb +13 -16
- data/lib/ffi-gobject_introspection/gobject_type_init.rb +18 -0
- data/lib/ffi-gobject_introspection/i_callable_info.rb +1 -5
- data/lib/ffi-gobject_introspection/i_constant_info.rb +3 -3
- data/lib/ffi-gobject_introspection/i_repository.rb +3 -47
- data/lib/ffi-gobject_introspection/i_vfunc_info.rb +3 -11
- data/lib/ffi-gobject_introspection/lib.rb +8 -31
- data/lib/{gir_ffi-base/glib → ffi-gobject_introspection}/strv.rb +9 -13
- data/lib/ffi-gobject_introspection.rb +47 -2
- data/lib/gir_ffi/allocation_helper.rb +1 -19
- data/lib/gir_ffi/arg_helper.rb +36 -26
- data/lib/{gir_ffi-base/glib → gir_ffi}/boolean.rb +7 -5
- data/lib/gir_ffi/boxed_base.rb +5 -23
- data/lib/gir_ffi/builder.rb +3 -3
- data/lib/gir_ffi/builders/argument_builder.rb +7 -8
- data/lib/gir_ffi/builders/base_argument_builder.rb +0 -1
- data/lib/gir_ffi/builders/callback_argument_builder.rb +2 -2
- data/lib/gir_ffi/builders/callback_return_value_builder.rb +21 -13
- data/lib/gir_ffi/builders/field_builder.rb +4 -10
- data/lib/gir_ffi/builders/module_builder.rb +6 -4
- data/lib/gir_ffi/builders/object_builder.rb +16 -16
- data/lib/gir_ffi/builders/struct_builder.rb +4 -6
- data/lib/gir_ffi/builders/struct_like.rb +1 -1
- data/lib/gir_ffi/builders/user_defined_builder.rb +83 -23
- data/lib/gir_ffi/builders/vfunc_argument_builder.rb +12 -17
- data/lib/gir_ffi/class_base.rb +0 -4
- data/lib/gir_ffi/core.rb +16 -13
- data/lib/gir_ffi/enum_base.rb +2 -41
- data/lib/gir_ffi/enum_like_base.rb +48 -0
- data/lib/gir_ffi/ffi_ext/pointer.rb +1 -1
- data/lib/gir_ffi/flags_base.rb +2 -41
- data/lib/gir_ffi/in_out_pointer.rb +1 -1
- data/lib/gir_ffi/in_pointer.rb +4 -4
- data/lib/gir_ffi/info_ext/i_type_info.rb +14 -5
- data/lib/gir_ffi/info_ext/i_vfunc_info.rb +8 -0
- data/lib/gir_ffi/module_base.rb +4 -0
- data/lib/gir_ffi/receiver_argument_info.rb +1 -1
- data/lib/gir_ffi/sized_array.rb +6 -6
- data/lib/gir_ffi/struct_base.rb +1 -6
- data/lib/gir_ffi/struct_like_base.rb +54 -45
- data/lib/gir_ffi/type_map.rb +6 -7
- data/lib/gir_ffi/union_base.rb +1 -1
- data/lib/gir_ffi/{user_defined_type_info.rb → user_defined_object_info.rb} +1 -2
- data/lib/gir_ffi/user_defined_property_info.rb +80 -2
- data/lib/gir_ffi/version.rb +1 -1
- data/lib/gir_ffi-base/gobject/lib.rb +0 -1
- data/lib/gir_ffi-base/gobject.rb +3 -5
- data/lib/gir_ffi-base.rb +3 -8
- data/tasks/test.rake +17 -3
- data/test/base_test_helper.rb +39 -23
- data/test/ffi-glib/closure_test.rb +37 -0
- data/test/ffi-glib/main_loop_test.rb +24 -0
- data/test/ffi-glib/ruby_closure_test.rb +0 -5
- data/test/ffi-gobject/object_test.rb +6 -10
- data/test/ffi-gobject/param_spec_test.rb +17 -5
- data/test/ffi-gobject/value_test.rb +15 -6
- data/test/ffi-gobject_introspection/gobject_type_init_test.rb +25 -0
- data/test/ffi-gobject_introspection/i_base_info_test.rb +1 -1
- data/test/ffi-gobject_introspection/i_repository_test.rb +18 -0
- data/test/ffi-gobject_introspection/i_vfunc_info_test.rb +40 -0
- data/test/{gir_ffi-base/glib → ffi-gobject_introspection}/strv_test.rb +8 -8
- data/test/gir_ffi/allocation_helper_test.rb +35 -0
- data/test/gir_ffi/arg_helper_test.rb +102 -7
- data/test/gir_ffi/boolean_test.rb +34 -0
- data/test/gir_ffi/boxed_base_test.rb +46 -6
- data/test/gir_ffi/builder_test.rb +88 -29
- data/test/gir_ffi/builders/argument_builder_test.rb +19 -0
- data/test/gir_ffi/builders/callback_argument_builder_test.rb +17 -0
- data/test/gir_ffi/builders/callback_return_value_builder_test.rb +1 -1
- data/test/gir_ffi/builders/field_builder_test.rb +2 -1
- data/test/gir_ffi/builders/struct_builder_test.rb +42 -25
- data/test/gir_ffi/builders/user_defined_builder_test.rb +365 -17
- data/test/gir_ffi/builders/vfunc_argument_builder_test.rb +100 -0
- data/test/gir_ffi/builders/vfunc_builder_test.rb +5 -3
- data/test/{gir_ffi_test.rb → gir_ffi/core_test.rb} +8 -6
- data/test/gir_ffi/in_out_pointer_test.rb +1 -1
- data/test/gir_ffi/receiver_argument_info_test.rb +32 -0
- data/test/gir_ffi/sized_array_test.rb +34 -0
- data/test/gir_ffi/struct_base_test.rb +4 -32
- data/test/gir_ffi/struct_like_base_test.rb +164 -0
- data/test/gir_ffi/union_base_test.rb +4 -20
- data/test/gir_ffi/{user_defined_type_info_test.rb → user_defined_object_info_test.rb} +10 -10
- data/test/gir_ffi/user_defined_property_info_test.rb +22 -5
- data/test/gir_ffi/version_test.rb +1 -1
- data/test/integration/callback_exceptions_test.rb +2 -0
- data/test/integration/derived_classes_test.rb +2 -0
- data/test/integration/generated_everything_test.rb +22 -0
- data/test/integration/generated_gimarshallingtests_test.rb +23 -21
- data/test/integration/generated_gio_test.rb +2 -0
- data/test/integration/generated_glib_test.rb +2 -0
- data/test/integration/generated_gst_test.rb +2 -0
- data/test/integration/generated_gtop_test.rb +2 -0
- data/test/integration/generated_regress_test.rb +113 -29
- data/test/integration/generated_secret_test.rb +2 -0
- data/test/integration/generated_warnlib_test.rb +2 -0
- data/test/integration/method_lookup_test.rb +2 -0
- data/test/introspection_test_helper.rb +15 -0
- metadata +21 -27
- data/lib/gir_ffi-base/glib.rb +0 -8
- data/test/gir_ffi-base/glib/boolean_test.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40ea5b819bf924354aa3422d6d50f16b273c2da6
|
4
|
+
data.tar.gz: 6da1f53d118bca0abccf87a2e4540bc6dc0f879f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2bc2ce1e2c881277554af8fe4e4b937518761f218b920442f56c0974caf67721751b2aee983acb02737e029fde356c5bbe71106bab0c73bf42311bd10021987
|
7
|
+
data.tar.gz: 0fe6972ea1da4b0dddd910efb36aeae78940bd4a3de5812b4e1dbe64fde8bd74795739e639f7bc17620121f37fe63a1e10a04559bf0d567d4c7aa13a1c440525
|
data/Changelog.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.11.0 / 2016-10-16
|
4
|
+
|
5
|
+
* Internal test and code improvements. Some internal APIs have been removed or
|
6
|
+
changed.
|
7
|
+
* Make Strv#each thread-safe.
|
8
|
+
* Drop support for CRuby 2.0.
|
9
|
+
* Move type_init and base Strv implementation into GObjectIntrospection, making
|
10
|
+
it stand-alone.
|
11
|
+
* Move GLib::Boolean to GirFFI::Boolean.
|
12
|
+
* Guard against instantiating abstract classes using the default constructor.
|
13
|
+
* Handle user-defined properties containing dashes
|
14
|
+
* Handle user-defined properties of a large number of types
|
15
|
+
|
3
16
|
## 0.10.2 / 2016-04-29
|
4
17
|
|
5
18
|
* Update ffi-bit_masks dependency and remove monkey-patch
|
data/Gemfile
CHANGED
@@ -4,13 +4,18 @@ source 'https://rubygems.org'
|
|
4
4
|
# The gem's dependencies are specified in gir_ffi.gemspec
|
5
5
|
gemspec
|
6
6
|
|
7
|
-
gem 'rubocop', '~> 0.
|
7
|
+
gem 'rubocop', '~> 0.43.0', group: :development
|
8
|
+
|
9
|
+
gem 'mutant', git: 'https://github.com/mbj/mutant.git',
|
10
|
+
branch: 'feature/minitest-integration',
|
11
|
+
platform: :mri_23,
|
12
|
+
group: :development
|
8
13
|
|
9
14
|
if ENV['CI']
|
10
15
|
if ENV['TRAVIS_RUBY_VERSION'] == '2.2'
|
11
|
-
gem 'coveralls',
|
16
|
+
gem 'coveralls', group: :development
|
12
17
|
end
|
13
18
|
else
|
14
|
-
gem 'simplecov', '~> 0.
|
15
|
-
gem 'pry', '~> 0.10.0',
|
19
|
+
gem 'simplecov', '~> 0.12.0', group: :development, platform: :mri
|
20
|
+
gem 'pry', '~> 0.10.0', group: :development
|
16
21
|
end
|
data/README.md
CHANGED
@@ -53,7 +53,7 @@ examples can be found in `gir_ffi-gtk` and `gir_ffi-gst`.
|
|
53
53
|
|
54
54
|
## Requirements
|
55
55
|
|
56
|
-
GirFFI is tested on CRuby 2.
|
56
|
+
GirFFI is tested on CRuby 2.1, 2.2 and 2.3, JRuby 9.0 and 9.1, and on
|
57
57
|
Rubinius 3.
|
58
58
|
|
59
59
|
You will also need gobject-introspection installed with some
|
@@ -70,10 +70,11 @@ On Debian and Ubuntu, installing `libgirepository1.0-1` and `gir1.2-glib-2.0`
|
|
70
70
|
should be enough to use GirFFI in your application.
|
71
71
|
|
72
72
|
To run the tests, you should additionally install `libgirepository1.0-dev`,
|
73
|
-
`gobject-introspection`, `gir1.2-gtop-2.0`, `gir1.2-pango-1.0`,
|
73
|
+
`libcairo2-dev`, `gobject-introspection`, `gir1.2-gtop-2.0`, `gir1.2-pango-1.0`,
|
74
74
|
`gir1.2-secret-1` and `gir1.2-gstreamer-1.0`. This should be enough to get
|
75
75
|
`rake test` working.
|
76
76
|
|
77
|
+
|
77
78
|
GirFFI has not been tested on Mac OS X or Microsoft Windows. YMMV.
|
78
79
|
|
79
80
|
## Overrides
|
data/Rakefile
CHANGED
data/lib/ffi-glib/byte_array.rb
CHANGED
data/lib/ffi-glib/main_loop.rb
CHANGED
data/lib/ffi-glib/strv.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module GLib
|
3
|
-
#
|
4
|
-
class
|
3
|
+
# Represents a null-terminated array of strings. GLib uses this construction,
|
4
|
+
# but does not provide any actual functions for this class.
|
5
|
+
#
|
6
|
+
# The implementation is mainly inherited from GObjectIntrospection::Strv.
|
7
|
+
class Strv < GObjectIntrospection::Strv
|
5
8
|
def ==(other)
|
6
9
|
to_a == other.to_a
|
7
10
|
end
|
data/lib/ffi-glib/variant.rb
CHANGED
@@ -19,15 +19,13 @@ module GLib
|
|
19
19
|
# NOTE: This is very hard to test since it is not possible to get the
|
20
20
|
# variant's ref count directely. However, there is an error when running
|
21
21
|
# the tests on 32-bit systems.
|
22
|
-
#
|
22
|
+
#
|
23
23
|
def store_pointer(ptr)
|
24
|
+
Lib.g_variant_ref_sink ptr
|
24
25
|
super
|
25
|
-
|
26
|
-
# TODO: Ensure ptr is not autorelease
|
27
|
-
::GLib::Lib.g_variant_ref_sink ptr
|
28
26
|
end
|
29
27
|
|
30
|
-
#
|
28
|
+
# For variants, wrap_copy does not do any copying.
|
31
29
|
def self.wrap_copy(val)
|
32
30
|
wrap(val)
|
33
31
|
end
|
data/lib/ffi-glib.rb
CHANGED
data/lib/ffi-gobject/closure.rb
CHANGED
@@ -13,7 +13,7 @@ module GObject
|
|
13
13
|
#
|
14
14
|
# @param [Proc] marshal The marshaller to use for this closure object
|
15
15
|
def set_marshal(marshal)
|
16
|
-
callback =
|
16
|
+
callback = ClosureMarshal.from marshal
|
17
17
|
Lib.g_closure_set_marshal self, callback
|
18
18
|
end
|
19
19
|
|
@@ -25,22 +25,20 @@ module GObject
|
|
25
25
|
#
|
26
26
|
# @param [GObject::Value] return_value The GValue to store the return
|
27
27
|
# value, or nil if no return value is expected.
|
28
|
-
# @param [Array] param_values the closure parameters
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
params = GirFFI::SizedArray.from(GObject::Value, -1, param_values)
|
35
|
-
GObject::Lib.g_closure_invoke self, rval, n_params, params, invocation_hint
|
28
|
+
# @param [Array] param_values the closure parameters.
|
29
|
+
def invoke(return_value, param_values)
|
30
|
+
rval = Value.from(return_value)
|
31
|
+
n_params = param_values.length
|
32
|
+
params = GirFFI::SizedArray.from(Value, -1, param_values)
|
33
|
+
Lib.g_closure_invoke self, rval, n_params, params, nil
|
36
34
|
rval.get_value
|
37
35
|
end
|
38
36
|
|
39
37
|
def store_pointer(ptr)
|
40
|
-
super
|
41
38
|
# NOTE: Call C functions directly to avoid extra argument conversion
|
42
39
|
Lib.g_closure_ref ptr
|
43
40
|
Lib.g_closure_sink ptr
|
41
|
+
super
|
44
42
|
end
|
45
43
|
end
|
46
44
|
end
|
data/lib/ffi-gobject/object.rb
CHANGED
@@ -35,14 +35,13 @@ module GObject
|
|
35
35
|
|
36
36
|
def store_pointer(ptr)
|
37
37
|
super
|
38
|
-
|
39
|
-
ObjectSpace.define_finalizer self, klass.make_finalizer(ptr, klass.name)
|
38
|
+
ObjectSpace.define_finalizer self, self.class.make_finalizer(ptr)
|
40
39
|
end
|
41
40
|
|
42
|
-
def self.make_finalizer(ptr
|
41
|
+
def self.make_finalizer(ptr)
|
43
42
|
proc do
|
44
43
|
rc = GObject::Object::Struct.new(ptr)[:ref_count]
|
45
|
-
if rc
|
44
|
+
if rc.zero?
|
46
45
|
warn "not unreffing #{name}:#{ptr} (#{rc})"
|
47
46
|
else
|
48
47
|
GObject::Lib.g_object_unref ptr
|
@@ -61,6 +60,10 @@ module GObject
|
|
61
60
|
super
|
62
61
|
end
|
63
62
|
|
63
|
+
def respond_to_missing?(*)
|
64
|
+
false
|
65
|
+
end
|
66
|
+
|
64
67
|
def signal_connect(event, data = nil, &block)
|
65
68
|
GObject.signal_connect(self, event, data, &block)
|
66
69
|
end
|
@@ -127,7 +130,7 @@ module GObject
|
|
127
130
|
raise GirFFI::PropertyNotFoundError.new(property_name, self.class)
|
128
131
|
end
|
129
132
|
|
130
|
-
# TODO: Move to ITypeInfo
|
133
|
+
# TODO: Move to ITypeInfo and unify with ArgHelper.cast_from_pointer
|
131
134
|
def property_value_post_conversion(val, type_info)
|
132
135
|
case type_info.flattened_tag
|
133
136
|
when :ghash
|
@@ -141,7 +144,7 @@ module GObject
|
|
141
144
|
end
|
142
145
|
end
|
143
146
|
|
144
|
-
# TODO: Move to ITypeInfo
|
147
|
+
# TODO: Move to ITypeInfo and unify with ArgHelper.cast_from_pointer
|
145
148
|
def property_value_pre_conversion(val, type_info)
|
146
149
|
case type_info.flattened_tag
|
147
150
|
when :ghash
|
data/lib/ffi-gobject/value.rb
CHANGED
@@ -6,18 +6,23 @@ module GObject
|
|
6
6
|
class Value
|
7
7
|
remove_method :init
|
8
8
|
|
9
|
+
def initialize
|
10
|
+
super
|
11
|
+
struct.owned = true
|
12
|
+
to_ptr.autorelease = nil
|
13
|
+
end
|
14
|
+
|
9
15
|
def init(type)
|
10
16
|
Lib.g_value_init self, type unless [TYPE_NONE, TYPE_INVALID].include? type
|
11
17
|
self
|
12
18
|
end
|
13
19
|
|
14
|
-
def self.make_finalizer(struct
|
20
|
+
def self.make_finalizer(struct)
|
15
21
|
proc do
|
16
|
-
|
17
|
-
|
18
|
-
ptr.autorelease = false
|
22
|
+
if struct.owned?
|
23
|
+
ptr = struct.to_ptr
|
19
24
|
unless struct[:g_type] == TYPE_INVALID
|
20
|
-
|
25
|
+
Lib.g_value_unset ptr
|
21
26
|
end
|
22
27
|
GObject.boxed_free gtype, ptr
|
23
28
|
end
|
@@ -110,17 +115,9 @@ module GObject
|
|
110
115
|
end
|
111
116
|
|
112
117
|
def self.copy_value_to_pointer(value, pointer, offset = 0)
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def self.copy(val)
|
120
|
-
return unless val
|
121
|
-
result = for_gtype(val.current_gtype)
|
122
|
-
Lib.g_value_copy val, result unless val.uninitialized?
|
123
|
-
result
|
118
|
+
target = wrap(pointer + offset)
|
119
|
+
target.init(value.current_gtype)
|
120
|
+
Lib.g_value_copy value, target unless value.uninitialized?
|
124
121
|
end
|
125
122
|
|
126
123
|
def uninitialized?
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'ffi'
|
3
|
+
|
4
|
+
module GObjectIntrospection
|
5
|
+
# Provides access to the g_type_init function.
|
6
|
+
module GObjectTypeInit
|
7
|
+
def self.type_init
|
8
|
+
Lib.g_type_init
|
9
|
+
end
|
10
|
+
|
11
|
+
# Module for attaching g_type_init from the gobject library.
|
12
|
+
module Lib
|
13
|
+
extend FFI::Library
|
14
|
+
ffi_lib 'gobject-2.0'
|
15
|
+
attach_function :g_type_init, [], :void
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -38,11 +38,7 @@ module GObjectIntrospection
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def instance_ownership_transfer
|
41
|
-
|
42
|
-
Lib.g_callable_info_get_instance_ownership_transfer @gobj
|
43
|
-
else
|
44
|
-
:nothing
|
45
|
-
end
|
41
|
+
Lib.g_callable_info_get_instance_ownership_transfer @gobj
|
46
42
|
end
|
47
43
|
end
|
48
44
|
end
|
@@ -21,14 +21,14 @@ module GObjectIntrospection
|
|
21
21
|
when :utf8
|
22
22
|
raw_value.force_encoding('utf-8')
|
23
23
|
when :gboolean
|
24
|
-
raw_value
|
24
|
+
raw_value.nonzero? ? true : false
|
25
25
|
else
|
26
26
|
raw_value
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
def constant_type
|
31
|
-
ITypeInfo.wrap Lib.g_constant_info_get_type
|
31
|
+
ITypeInfo.wrap Lib.g_constant_info_get_type self
|
32
32
|
end
|
33
33
|
|
34
34
|
private
|
@@ -39,7 +39,7 @@ module GObjectIntrospection
|
|
39
39
|
|
40
40
|
def raw_value
|
41
41
|
value_union = Lib::GIArgument.new
|
42
|
-
Lib.g_constant_info_get_value
|
42
|
+
Lib.g_constant_info_get_value self, value_union
|
43
43
|
value_union[union_member_key]
|
44
44
|
end
|
45
45
|
|
@@ -2,58 +2,14 @@
|
|
2
2
|
require 'singleton'
|
3
3
|
|
4
4
|
require 'ffi-gobject_introspection/lib'
|
5
|
+
require 'ffi-gobject_introspection/strv'
|
5
6
|
require 'ffi-gobject_introspection/g_error'
|
6
|
-
require 'ffi-gobject_introspection/i_base_info'
|
7
|
-
require 'ffi-gobject_introspection/i_callable_info'
|
8
|
-
require 'ffi-gobject_introspection/i_callback_info'
|
9
|
-
require 'ffi-gobject_introspection/i_function_info'
|
10
|
-
require 'ffi-gobject_introspection/i_constant_info'
|
11
|
-
require 'ffi-gobject_introspection/i_field_info'
|
12
|
-
require 'ffi-gobject_introspection/i_registered_type_info'
|
13
|
-
require 'ffi-gobject_introspection/i_interface_info'
|
14
|
-
require 'ffi-gobject_introspection/i_property_info'
|
15
|
-
require 'ffi-gobject_introspection/i_vfunc_info'
|
16
|
-
require 'ffi-gobject_introspection/i_signal_info'
|
17
|
-
require 'ffi-gobject_introspection/i_object_info'
|
18
|
-
require 'ffi-gobject_introspection/i_struct_info'
|
19
|
-
require 'ffi-gobject_introspection/i_value_info'
|
20
|
-
require 'ffi-gobject_introspection/i_union_info'
|
21
|
-
require 'ffi-gobject_introspection/i_enum_info'
|
22
|
-
require 'ffi-gobject_introspection/i_flags_info'
|
23
|
-
require 'ffi-gobject_introspection/i_unresolved_info'
|
24
7
|
|
25
8
|
module GObjectIntrospection
|
26
9
|
# The Gobject Introspection Repository. This class is the point of
|
27
10
|
# access to the introspection typelibs.
|
28
11
|
# This class wraps the GIRepository struct.
|
29
12
|
class IRepository
|
30
|
-
# Map info type to class. Default is IBaseInfo.
|
31
|
-
# SMELL: This doesn't really belong here, since it is used by IBaseInfo and
|
32
|
-
# descendants as well.
|
33
|
-
TYPEMAP = {
|
34
|
-
invalid: IBaseInfo,
|
35
|
-
function: IFunctionInfo,
|
36
|
-
callback: ICallbackInfo,
|
37
|
-
struct: IStructInfo,
|
38
|
-
# TODO: There's no GIBoxedInfo, so what does :boxed mean?
|
39
|
-
boxed: IBaseInfo,
|
40
|
-
enum: IEnumInfo,
|
41
|
-
flags: IFlagsInfo,
|
42
|
-
object: IObjectInfo,
|
43
|
-
interface: IInterfaceInfo,
|
44
|
-
constant: IConstantInfo,
|
45
|
-
invalid_was_error_domain: IBaseInfo,
|
46
|
-
union: IUnionInfo,
|
47
|
-
value: IValueInfo,
|
48
|
-
signal: ISignalInfo,
|
49
|
-
vfunc: IVFuncInfo,
|
50
|
-
property: IPropertyInfo,
|
51
|
-
field: IFieldInfo,
|
52
|
-
arg: IArgInfo,
|
53
|
-
type: ITypeInfo,
|
54
|
-
unresolved: IUnresolvedInfo
|
55
|
-
}.freeze
|
56
|
-
|
57
13
|
def initialize
|
58
14
|
@gobj = Lib.g_irepository_get_default
|
59
15
|
end
|
@@ -101,13 +57,13 @@ module GObjectIntrospection
|
|
101
57
|
end
|
102
58
|
|
103
59
|
def find_by_gtype(gtype)
|
104
|
-
raise ArgumentError, "Type #{gtype} is not a valid type" if gtype
|
60
|
+
raise ArgumentError, "Type #{gtype} is not a valid type" if gtype.zero?
|
105
61
|
wrap_info Lib.g_irepository_find_by_gtype(@gobj, gtype)
|
106
62
|
end
|
107
63
|
|
108
64
|
def dependencies(namespace)
|
109
65
|
strv_p = Lib.g_irepository_get_dependencies(@gobj, namespace)
|
110
|
-
strv =
|
66
|
+
strv = Strv.new strv_p
|
111
67
|
strv.to_a
|
112
68
|
end
|
113
69
|
|
@@ -4,23 +4,15 @@ module GObjectIntrospection
|
|
4
4
|
# Represents a virtual function.
|
5
5
|
class IVFuncInfo < ICallableInfo
|
6
6
|
def flags
|
7
|
-
Lib.g_vfunc_info_get_flags
|
7
|
+
Lib.g_vfunc_info_get_flags self
|
8
8
|
end
|
9
9
|
|
10
10
|
def throws?
|
11
|
-
flags
|
12
|
-
end
|
13
|
-
|
14
|
-
def offset
|
15
|
-
Lib.g_vfunc_info_get_offset @gobj
|
16
|
-
end
|
17
|
-
|
18
|
-
def signal
|
19
|
-
ISignalInfo.wrap Lib.g_vfunc_info_get_signal(@gobj)
|
11
|
+
flags.fetch :throws
|
20
12
|
end
|
21
13
|
|
22
14
|
def invoker
|
23
|
-
IFunctionInfo.wrap Lib.g_vfunc_info_get_invoker
|
15
|
+
IFunctionInfo.wrap Lib.g_vfunc_info_get_invoker self
|
24
16
|
end
|
25
17
|
end
|
26
18
|
end
|
@@ -9,25 +9,6 @@ module GObjectIntrospection
|
|
9
9
|
extend FFI::BitMasks
|
10
10
|
ffi_lib 'girepository-1.0'
|
11
11
|
|
12
|
-
# Helper class to support guessing the gobject-introspection version.
|
13
|
-
# Provide several guesses to #provide_guess, and the result in #best_guess
|
14
|
-
# will be the best (i.e., lowest) guess.
|
15
|
-
class VersionGuesser
|
16
|
-
def initialize(base)
|
17
|
-
@guess = base
|
18
|
-
end
|
19
|
-
|
20
|
-
def provide_guess(guessed)
|
21
|
-
@guess = guessed if guessed < @guess
|
22
|
-
end
|
23
|
-
|
24
|
-
def best_guess
|
25
|
-
@guess
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
version_guesser = VersionGuesser.new('1.42')
|
30
|
-
|
31
12
|
# IRepository
|
32
13
|
enum :IRepositoryLoadFlags, [:LAZY, (1 << 0)]
|
33
14
|
|
@@ -102,17 +83,12 @@ module GObjectIntrospection
|
|
102
83
|
attach_function :g_callable_info_get_caller_owns, [:pointer], :ITransfer
|
103
84
|
attach_function :g_callable_info_may_return_null, [:pointer], :bool
|
104
85
|
attach_function :g_callable_info_can_throw_gerror, [:pointer], :bool
|
86
|
+
attach_function :g_callable_info_get_instance_ownership_transfer,
|
87
|
+
[:pointer], :ITransfer
|
105
88
|
attach_function :g_callable_info_get_n_args, [:pointer], :int
|
106
89
|
attach_function :g_callable_info_get_arg, [:pointer, :int], :pointer
|
107
90
|
attach_function :g_callable_info_skip_return, [:pointer], :bool
|
108
91
|
|
109
|
-
begin
|
110
|
-
attach_function :g_callable_info_get_instance_ownership_transfer,
|
111
|
-
[:pointer], :ITransfer
|
112
|
-
rescue FFI::NotFoundError
|
113
|
-
version_guesser.provide_guess '1.40'
|
114
|
-
end
|
115
|
-
|
116
92
|
# IArgInfo
|
117
93
|
enum :IDirection, [
|
118
94
|
:in,
|
@@ -242,10 +218,13 @@ module GObjectIntrospection
|
|
242
218
|
attach_function :g_object_info_get_fundamental, [:pointer], :bool
|
243
219
|
|
244
220
|
# IVFuncInfo
|
221
|
+
bit_mask :IVFuncInfoFlags,
|
222
|
+
must_chain_up: (1 << 0),
|
223
|
+
must_override: (1 << 1),
|
224
|
+
must_not_override: (1 << 2),
|
225
|
+
throws: (1 << 3)
|
245
226
|
|
246
|
-
attach_function :g_vfunc_info_get_flags, [:pointer], :
|
247
|
-
attach_function :g_vfunc_info_get_offset, [:pointer], :int
|
248
|
-
attach_function :g_vfunc_info_get_signal, [:pointer], :pointer
|
227
|
+
attach_function :g_vfunc_info_get_flags, [:pointer], :IVFuncInfoFlags
|
249
228
|
attach_function :g_vfunc_info_get_invoker, [:pointer], :pointer
|
250
229
|
|
251
230
|
# IInterfaceInfo
|
@@ -309,7 +288,5 @@ module GObjectIntrospection
|
|
309
288
|
construct_only: (1 << 3)
|
310
289
|
|
311
290
|
attach_function :g_property_info_get_flags, [:pointer], :ParamFlags
|
312
|
-
|
313
|
-
::GObjectIntrospection::VERSION = version_guesser.best_guess
|
314
291
|
end
|
315
292
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'ffi'
|
3
|
-
require 'gir_ffi-base/glib'
|
4
3
|
|
5
|
-
module
|
6
|
-
# Represents a null-terminated array of strings.
|
4
|
+
module GObjectIntrospection
|
5
|
+
# Represents a null-terminated array of strings.
|
6
|
+
# GLib uses this
|
7
7
|
# construction, but does not provide any actual functions for this class.
|
8
8
|
class Strv
|
9
9
|
include Enumerable
|
@@ -19,9 +19,9 @@ module GLib
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def each
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
offset = 0
|
23
|
+
while (ptr = fetch_ptr offset)
|
24
|
+
offset += POINTER_SIZE
|
25
25
|
yield ptr.read_string
|
26
26
|
end
|
27
27
|
end
|
@@ -32,13 +32,9 @@ module GLib
|
|
32
32
|
|
33
33
|
private
|
34
34
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
def next_ptr
|
40
|
-
ptr = @ptr.get_pointer @offset
|
41
|
-
@offset += POINTER_SIZE
|
35
|
+
def fetch_ptr(offset)
|
36
|
+
return if @ptr.null?
|
37
|
+
ptr = @ptr.get_pointer offset
|
42
38
|
ptr unless ptr.null?
|
43
39
|
end
|
44
40
|
end
|
@@ -1,6 +1,51 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require '
|
2
|
+
require 'ffi-gobject_introspection/gobject_type_init'
|
3
|
+
GObjectIntrospection::GObjectTypeInit.type_init
|
3
4
|
|
4
|
-
|
5
|
+
require 'ffi-gobject_introspection/i_base_info'
|
6
|
+
require 'ffi-gobject_introspection/i_callable_info'
|
7
|
+
require 'ffi-gobject_introspection/i_callback_info'
|
8
|
+
require 'ffi-gobject_introspection/i_function_info'
|
9
|
+
require 'ffi-gobject_introspection/i_constant_info'
|
10
|
+
require 'ffi-gobject_introspection/i_field_info'
|
11
|
+
require 'ffi-gobject_introspection/i_registered_type_info'
|
12
|
+
require 'ffi-gobject_introspection/i_interface_info'
|
13
|
+
require 'ffi-gobject_introspection/i_property_info'
|
14
|
+
require 'ffi-gobject_introspection/i_vfunc_info'
|
15
|
+
require 'ffi-gobject_introspection/i_signal_info'
|
16
|
+
require 'ffi-gobject_introspection/i_object_info'
|
17
|
+
require 'ffi-gobject_introspection/i_struct_info'
|
18
|
+
require 'ffi-gobject_introspection/i_value_info'
|
19
|
+
require 'ffi-gobject_introspection/i_union_info'
|
20
|
+
require 'ffi-gobject_introspection/i_enum_info'
|
21
|
+
require 'ffi-gobject_introspection/i_flags_info'
|
22
|
+
require 'ffi-gobject_introspection/i_unresolved_info'
|
23
|
+
|
24
|
+
module GObjectIntrospection
|
25
|
+
# Map info type to class. Default is IBaseInfo.
|
26
|
+
TYPEMAP = {
|
27
|
+
invalid: IBaseInfo,
|
28
|
+
function: IFunctionInfo,
|
29
|
+
callback: ICallbackInfo,
|
30
|
+
struct: IStructInfo,
|
31
|
+
# TODO: There's no GIBoxedInfo, so what does :boxed mean?
|
32
|
+
boxed: IBaseInfo,
|
33
|
+
enum: IEnumInfo,
|
34
|
+
flags: IFlagsInfo,
|
35
|
+
object: IObjectInfo,
|
36
|
+
interface: IInterfaceInfo,
|
37
|
+
constant: IConstantInfo,
|
38
|
+
invalid_was_error_domain: IBaseInfo,
|
39
|
+
union: IUnionInfo,
|
40
|
+
value: IValueInfo,
|
41
|
+
signal: ISignalInfo,
|
42
|
+
vfunc: IVFuncInfo,
|
43
|
+
property: IPropertyInfo,
|
44
|
+
field: IFieldInfo,
|
45
|
+
arg: IArgInfo,
|
46
|
+
type: ITypeInfo,
|
47
|
+
unresolved: IUnresolvedInfo
|
48
|
+
}.freeze
|
49
|
+
end
|
5
50
|
|
6
51
|
require 'ffi-gobject_introspection/i_repository'
|
@@ -2,26 +2,8 @@
|
|
2
2
|
require 'gir_ffi/lib_c'
|
3
3
|
|
4
4
|
module GirFFI
|
5
|
-
# Helper module
|
6
|
-
# if memory cannot be allocated.
|
5
|
+
# Helper module for alloction-related functionality.
|
7
6
|
module AllocationHelper
|
8
|
-
# NOTE: It would be preferable to use FFI::MemoryPointer.new(size), but
|
9
|
-
# there is a bug in FFI which means this gives a problem:
|
10
|
-
# # let ptr be a pointer not allocated by FFI.
|
11
|
-
# ptr2 = FFI::MemoryPointer.new(1)
|
12
|
-
# ptr.put_pointer ptr2 # This raises an out-of-bounds error.
|
13
|
-
# This occurs in method_int8_arg_and_out_callee
|
14
|
-
def self.safe_malloc(size)
|
15
|
-
ptr = LibC.malloc size
|
16
|
-
raise NoMemoryError if ptr.null?
|
17
|
-
ptr
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.allocate(type)
|
21
|
-
type_size = FFI.type_size type
|
22
|
-
safe_malloc(type_size)
|
23
|
-
end
|
24
|
-
|
25
7
|
def self.free_after(ptr)
|
26
8
|
result = yield ptr
|
27
9
|
LibC.free ptr unless ptr.null?
|