gir_ffi 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +5 -0
- data/TODO.md +13 -0
- data/lib/ffi-gobject_introspection/i_property_info.rb +20 -0
- data/lib/ffi-gobject_introspection/lib.rb +2 -0
- data/lib/gir_ffi/builders/argument_builder_collection.rb +1 -1
- data/lib/gir_ffi/builders/callback_return_value_builder.rb +7 -3
- data/lib/gir_ffi/builders/closure_return_value_builder.rb +14 -0
- data/lib/gir_ffi/builders/marshalling_method_builder.rb +2 -2
- data/lib/gir_ffi/builders/property_builder.rb +5 -1
- data/lib/gir_ffi/info_ext/i_type_info.rb +4 -0
- data/lib/gir_ffi/version.rb +1 -1
- data/test/ffi-gobject_introspection/i_property_info_test.rb +44 -0
- data/test/gir_ffi/builders/signal_closure_builder_test.rb +22 -0
- data/test/gir_ffi_test_helper.rb +0 -20
- data/test/integration/generated_gio_test.rb +16 -0
- data/test/integration/generated_gobject_test.rb +29 -0
- data/test/introspection_test_helper.rb +20 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be09f0c7b882ddc0bb3dfdc7d0c78a799f364523
|
4
|
+
data.tar.gz: 0a5cff8324417259a1092c686e9d3ffc492efebf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26639dd911992a83273376f6421f9eee8f802386d3b345a62feacd4b6a7d5fac9f7cc55cba160428ceb59c7e4740404b990761892fddef705bb4dd94bcf1fa21
|
7
|
+
data.tar.gz: 63a71dd6cf133b0e7f0dcaf335961297b968e3cc3293170e9f5b9daf9709ad6562cc1df92e8c4b4749af61b9966a8540153a316002ef2b0b8bf817dd02199837
|
data/Changelog.md
CHANGED
data/TODO.md
CHANGED
@@ -65,6 +65,19 @@ It would be good to replace this with something that's easier to use:
|
|
65
65
|
Ruby-GNOME do
|
66
66
|
* What about properties?
|
67
67
|
|
68
|
+
How about:
|
69
|
+
|
70
|
+
class Derived < Base
|
71
|
+
include SomeGObjectInterface
|
72
|
+
|
73
|
+
register_type 'Derived'
|
74
|
+
|
75
|
+
install_property ...
|
76
|
+
install_vfunc_implementation ...
|
77
|
+
end
|
78
|
+
|
79
|
+
This needs issue #63 to be resolved.
|
80
|
+
|
68
81
|
## Persistent Ruby GObject identity
|
69
82
|
|
70
83
|
GirFFI should make sure that if it gets a pointer to a GObject for which a Ruby
|
@@ -5,5 +5,25 @@ module GObjectIntrospection
|
|
5
5
|
def property_type
|
6
6
|
ITypeInfo.wrap(Lib.g_property_info_get_type @gobj)
|
7
7
|
end
|
8
|
+
|
9
|
+
def flags
|
10
|
+
Lib.g_property_info_get_flags @gobj
|
11
|
+
end
|
12
|
+
|
13
|
+
def readable?
|
14
|
+
flags & 1 != 0
|
15
|
+
end
|
16
|
+
|
17
|
+
def writeable?
|
18
|
+
flags & 2 != 0
|
19
|
+
end
|
20
|
+
|
21
|
+
def construct?
|
22
|
+
flags & 4 != 0
|
23
|
+
end
|
24
|
+
|
25
|
+
def construct_only?
|
26
|
+
flags & 8 != 0
|
27
|
+
end
|
8
28
|
end
|
9
29
|
end
|
@@ -289,6 +289,8 @@ module GObjectIntrospection
|
|
289
289
|
# IPropertyInfo
|
290
290
|
#
|
291
291
|
attach_function :g_property_info_get_type, [:pointer], :pointer
|
292
|
+
# TODO: return type is bitfield
|
293
|
+
attach_function :g_property_info_get_flags, [:pointer], :int
|
292
294
|
|
293
295
|
::GObjectIntrospection::VERSION = version_guesser.best_guess
|
294
296
|
end
|
@@ -38,12 +38,16 @@ module GirFFI
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
private
|
42
|
-
|
43
41
|
def has_post_conversion?
|
44
|
-
|
42
|
+
relevant? && needs_ruby_to_c_conversion?
|
43
|
+
end
|
44
|
+
|
45
|
+
def needs_ruby_to_c_conversion?
|
46
|
+
type_info.needs_ruby_to_c_conversion_for_callbacks?
|
45
47
|
end
|
46
48
|
|
49
|
+
private
|
50
|
+
|
47
51
|
def post_convertor
|
48
52
|
@post_convertor ||= RubyToCConvertor.new(type_info, post_convertor_argument)
|
49
53
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'gir_ffi/builders/callback_return_value_builder'
|
2
|
+
|
3
|
+
module GirFFI
|
4
|
+
module Builders
|
5
|
+
# Implements building post-processing statements for return values of
|
6
|
+
# closures.
|
7
|
+
class ClosureReturnValueBuilder < CallbackReturnValueBuilder
|
8
|
+
def needs_ruby_to_c_conversion?
|
9
|
+
type_info.needs_ruby_to_c_conversion_for_closures?
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'gir_ffi/variable_name_generator'
|
2
2
|
require 'gir_ffi/builders/closure_argument_builder'
|
3
|
-
require 'gir_ffi/builders/
|
3
|
+
require 'gir_ffi/builders/closure_return_value_builder'
|
4
4
|
require 'gir_ffi/builders/argument_builder_collection'
|
5
5
|
require 'gir_ffi/builders/method_template'
|
6
6
|
|
@@ -20,7 +20,7 @@ module GirFFI
|
|
20
20
|
receiver_builder = make_argument_builder receiver_info
|
21
21
|
argument_builders = argument_infos.map { |arg| make_argument_builder arg }
|
22
22
|
return_value_builder =
|
23
|
-
|
23
|
+
ClosureReturnValueBuilder.new(variable_generator, return_value_info)
|
24
24
|
|
25
25
|
@argument_builder_collection =
|
26
26
|
ArgumentBuilderCollection.new(return_value_builder, argument_builders,
|
@@ -8,7 +8,7 @@ module GirFFI
|
|
8
8
|
|
9
9
|
def build
|
10
10
|
setup_getter
|
11
|
-
setup_setter
|
11
|
+
setup_setter if setting_allowed
|
12
12
|
end
|
13
13
|
|
14
14
|
def setup_getter
|
@@ -123,6 +123,10 @@ module GirFFI
|
|
123
123
|
def container_info
|
124
124
|
@container_info ||= @info.container
|
125
125
|
end
|
126
|
+
|
127
|
+
def setting_allowed
|
128
|
+
@info.writeable? && !@info.construct_only?
|
129
|
+
end
|
126
130
|
end
|
127
131
|
end
|
128
132
|
end
|
@@ -163,6 +163,10 @@ module GirFFI
|
|
163
163
|
[:array, :c, :ghash, :struct, :strv].include?(flattened_tag)
|
164
164
|
end
|
165
165
|
|
166
|
+
def needs_ruby_to_c_conversion_for_closures?
|
167
|
+
[:array].include?(flattened_tag)
|
168
|
+
end
|
169
|
+
|
166
170
|
def extra_conversion_arguments
|
167
171
|
case flattened_tag
|
168
172
|
when :utf8, :void
|
data/lib/gir_ffi/version.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'introspection_test_helper'
|
2
|
+
|
3
|
+
describe GObjectIntrospection::IPropertyInfo do
|
4
|
+
describe "for Regress::TestObj's 'double' property" do
|
5
|
+
let(:property_info) { get_property_introspection_data 'Regress', 'TestObj', 'double' }
|
6
|
+
|
7
|
+
it 'returns :gdouble as its type' do
|
8
|
+
property_info.property_type.tag.must_equal :gdouble
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'flags the property as readable' do
|
12
|
+
property_info.readable?.must_equal true
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'flags the property as writeable' do
|
16
|
+
property_info.writeable?.must_equal true
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'flags the property as not construct-only' do
|
20
|
+
property_info.construct_only?.must_equal false
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "for GObject::Binding's 'target-property' property" do
|
25
|
+
let(:property_info) {
|
26
|
+
get_property_introspection_data 'GObject', 'Binding', 'target-property' }
|
27
|
+
|
28
|
+
it 'returns :utf8 as its type' do
|
29
|
+
property_info.property_type.tag.must_equal :utf8
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'flags the property as readable' do
|
33
|
+
property_info.readable?.must_equal true
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'flags the property as writeable' do
|
37
|
+
property_info.writeable?.must_equal true
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'flags the property as construct-only' do
|
41
|
+
property_info.construct_only?.must_equal true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -139,5 +139,27 @@ describe GirFFI::Builders::SignalClosureBuilder do
|
|
139
139
|
builder.marshaller_definition.must_equal expected
|
140
140
|
end
|
141
141
|
end
|
142
|
+
|
143
|
+
describe 'for a signal returning an string' do
|
144
|
+
let(:signal_info) do
|
145
|
+
get_signal_introspection_data 'Gtk', 'Scale', 'format-value'
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'returns a mapping method that passes the string result to return_value directly' do
|
149
|
+
skip unless signal_info
|
150
|
+
|
151
|
+
expected = <<-CODE.reset_indentation
|
152
|
+
def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
|
153
|
+
_instance, value = param_values.map(&:get_value_plain)
|
154
|
+
_v1 = _instance
|
155
|
+
_v2 = value
|
156
|
+
_v3 = wrap(closure.to_ptr).invoke_block(_v1, _v2)
|
157
|
+
return_value.set_value _v3
|
158
|
+
end
|
159
|
+
CODE
|
160
|
+
|
161
|
+
builder.marshaller_definition.must_equal expected
|
162
|
+
end
|
163
|
+
end
|
142
164
|
end
|
143
165
|
end
|
data/test/gir_ffi_test_helper.rb
CHANGED
@@ -11,26 +11,6 @@ class Sequence
|
|
11
11
|
end
|
12
12
|
|
13
13
|
module GirFFITestExtensions
|
14
|
-
def get_field_introspection_data(namespace, klass, name)
|
15
|
-
get_introspection_data(namespace, klass).find_field name
|
16
|
-
end
|
17
|
-
|
18
|
-
def get_method_introspection_data(namespace, klass, name)
|
19
|
-
get_introspection_data(namespace, klass).find_method name
|
20
|
-
end
|
21
|
-
|
22
|
-
def get_property_introspection_data(namespace, klass, name)
|
23
|
-
get_introspection_data(namespace, klass).find_property name
|
24
|
-
end
|
25
|
-
|
26
|
-
def get_signal_introspection_data(namespace, klass, name)
|
27
|
-
get_introspection_data(namespace, klass).find_signal name
|
28
|
-
end
|
29
|
-
|
30
|
-
def get_vfunc_introspection_data(namespace, klass, name)
|
31
|
-
get_introspection_data(namespace, klass).find_vfunc name
|
32
|
-
end
|
33
|
-
|
34
14
|
SAVED_MODULES = {}
|
35
15
|
|
36
16
|
def save_module(name)
|
@@ -98,4 +98,20 @@ describe 'The generated Gio module' do
|
|
98
98
|
Gio::SocketSourceFunc.new { |*args| p args }.to_native
|
99
99
|
end
|
100
100
|
end
|
101
|
+
|
102
|
+
describe 'Gio::SimpleAction' do
|
103
|
+
let(:simple_action) { Gio::SimpleAction.new('test', 'd') }
|
104
|
+
|
105
|
+
it 'can read the property "state-type" with #get_property' do
|
106
|
+
simple_action.get_property('state-type').get_value.must_be_nil
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'can read the property "state-type" with #state_type' do
|
110
|
+
simple_action.state_type.must_be_nil
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'cannot write the property "state-type" with #state_type=' do
|
114
|
+
proc { simple_action.state_type = nil }.must_raise NoMethodError
|
115
|
+
end
|
116
|
+
end
|
101
117
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'gir_ffi_test_helper'
|
2
2
|
|
3
|
+
GirFFI.setup :Regress
|
4
|
+
|
3
5
|
describe GObject do
|
4
6
|
describe '.type_interfaces' do
|
5
7
|
it 'works, showing that returning an array of GType works' do
|
@@ -72,4 +74,31 @@ describe GObject do
|
|
72
74
|
signal_query.param_types.size.must_equal 1
|
73
75
|
end
|
74
76
|
end
|
77
|
+
|
78
|
+
describe GObject::Binding do
|
79
|
+
it 'is created with GObject::Object#bind_property' do
|
80
|
+
source = Regress::TestObj.constructor
|
81
|
+
target = Regress::TestObj.constructor
|
82
|
+
binding = source.bind_property 'double', target, 'double', :default
|
83
|
+
binding.must_be_kind_of GObject::Binding
|
84
|
+
end
|
85
|
+
|
86
|
+
describe 'an instance' do
|
87
|
+
let(:source) { Regress::TestObj.constructor }
|
88
|
+
let(:target) { Regress::TestObj.constructor }
|
89
|
+
let(:binding) { source.bind_property 'double', target, 'double', :default }
|
90
|
+
|
91
|
+
it 'can read the property "target-property" with #get_property' do
|
92
|
+
binding.get_property('target-property').get_value.must_equal 'double'
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'can read the property "target-property" with #target_property' do
|
96
|
+
binding.target_property.must_equal 'double'
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'cannot write the property "target-property" with #target_property=' do
|
100
|
+
proc { binding.target_property = 'foo' }.must_raise NoMethodError
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
75
104
|
end
|
@@ -8,6 +8,26 @@ module IntrospectionTestExtensions
|
|
8
8
|
gir.require namespace, nil
|
9
9
|
gir.find_by_name namespace, name
|
10
10
|
end
|
11
|
+
|
12
|
+
def get_field_introspection_data(namespace, klass, name)
|
13
|
+
get_introspection_data(namespace, klass).find_field name
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_method_introspection_data(namespace, klass, name)
|
17
|
+
get_introspection_data(namespace, klass).find_method name
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_property_introspection_data(namespace, klass, name)
|
21
|
+
get_introspection_data(namespace, klass).find_property name
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_signal_introspection_data(namespace, klass, name)
|
25
|
+
get_introspection_data(namespace, klass).find_signal name
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_vfunc_introspection_data(namespace, klass, name)
|
29
|
+
get_introspection_data(namespace, klass).find_vfunc name
|
30
|
+
end
|
11
31
|
end
|
12
32
|
|
13
33
|
Minitest::Test.send :include, IntrospectionTestExtensions
|
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.8.
|
4
|
+
version: 0.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matijs van Zuijlen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -174,6 +174,7 @@ files:
|
|
174
174
|
- lib/gir_ffi/builders/callback_return_value_builder.rb
|
175
175
|
- lib/gir_ffi/builders/closure_argument_builder.rb
|
176
176
|
- lib/gir_ffi/builders/closure_convertor.rb
|
177
|
+
- lib/gir_ffi/builders/closure_return_value_builder.rb
|
177
178
|
- lib/gir_ffi/builders/closure_to_pointer_convertor.rb
|
178
179
|
- lib/gir_ffi/builders/constant_builder.rb
|
179
180
|
- lib/gir_ffi/builders/constructor_builder.rb
|
@@ -281,6 +282,7 @@ files:
|
|
281
282
|
- test/ffi-gobject_introspection/i_function_info_test.rb
|
282
283
|
- test/ffi-gobject_introspection/i_interface_info_test.rb
|
283
284
|
- test/ffi-gobject_introspection/i_object_info_test.rb
|
285
|
+
- test/ffi-gobject_introspection/i_property_info_test.rb
|
284
286
|
- test/ffi-gobject_introspection/i_registered_type_info_test.rb
|
285
287
|
- test/ffi-gobject_introspection/i_repository_test.rb
|
286
288
|
- test/ffi-gobject_introspection/i_struct_info_test.rb
|