gir_ffi 0.0.13 → 0.0.14
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.
- data/History.txt +8 -0
- data/lib/gir_ffi/builder/module.rb +1 -0
- data/lib/gir_ffi/builder/type/base.rb +1 -1
- data/lib/gir_ffi/builder/type/registered_type.rb +4 -0
- data/lib/gir_ffi/builder/type/with_layout.rb +6 -5
- data/lib/gir_ffi/builder.rb +1 -0
- data/lib/gir_ffi/i_base_info.rb +8 -0
- data/lib/gir_ffi/overrides/gobject.rb +30 -24
- data/lib/gir_ffi/version.rb +1 -1
- data/test/type_builder_test.rb +33 -1
- data/test/unit/i_base_info_test.rb +16 -0
- metadata +7 -6
data/History.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
== 0.0.14 / 2011-10-28
|
2
|
+
|
3
|
+
* Support GObject Introspection version 1.30:
|
4
|
+
- Add support for layouts with fixed-length arrays.
|
5
|
+
- Handle type names starting with underscores.
|
6
|
+
- Call g_signal_emitv directly to avoid conflict in introspection info
|
7
|
+
with earlier versions of GObject Introspection.
|
8
|
+
|
1
9
|
== 0.0.13 / 2011-09-09
|
2
10
|
|
3
11
|
* Remove IErrorDomain related code. This functinality was removed from
|
@@ -31,11 +31,12 @@ module GirFFI
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
fields.
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
fields.inject([]) do |spec, finfo|
|
35
|
+
spec +
|
36
|
+
[ finfo.name.to_sym,
|
37
|
+
itypeinfo_to_ffitype_for_struct(finfo.field_type),
|
38
|
+
finfo.offset ]
|
39
|
+
end
|
39
40
|
end
|
40
41
|
end
|
41
42
|
end
|
data/lib/gir_ffi/builder.rb
CHANGED
data/lib/gir_ffi/i_base_info.rb
CHANGED
@@ -6,6 +6,7 @@ module GirFFI
|
|
6
6
|
base.extend ClassMethods
|
7
7
|
extend_classes(base)
|
8
8
|
attach_non_introspectable_functions(base)
|
9
|
+
preload_methods(base)
|
9
10
|
build_extra_classes(base)
|
10
11
|
end
|
11
12
|
|
@@ -29,6 +30,10 @@ module GirFFI
|
|
29
30
|
[:pointer, base::ClosureMarshal], :void
|
30
31
|
end
|
31
32
|
|
33
|
+
def self.preload_methods base
|
34
|
+
base._setup_method :signal_emitv
|
35
|
+
end
|
36
|
+
|
32
37
|
def self.build_extra_classes base
|
33
38
|
build_ruby_closure_class base
|
34
39
|
end
|
@@ -99,7 +104,7 @@ module GirFFI
|
|
99
104
|
arr = Helper.signal_arguments_to_gvalue_array signal, object, *args
|
100
105
|
rval = Helper.gvalue_for_signal_return_value signal, object
|
101
106
|
|
102
|
-
|
107
|
+
::GObject::Lib.g_signal_emitv arr[:values], id, 0, rval
|
103
108
|
|
104
109
|
rval
|
105
110
|
end
|
@@ -129,7 +134,9 @@ module GirFFI
|
|
129
134
|
|
130
135
|
module Helper
|
131
136
|
TAG_TYPE_TO_GTYPE_NAME_MAP = {
|
132
|
-
:utf8 => "gchararray"
|
137
|
+
:utf8 => "gchararray",
|
138
|
+
:gboolean => "gboolean",
|
139
|
+
:void => "void"
|
133
140
|
}
|
134
141
|
|
135
142
|
def self.signal_callback_args sig, klass, &block
|
@@ -162,13 +169,11 @@ module GirFFI
|
|
162
169
|
|
163
170
|
def self.signal_argument_to_gvalue info, arg
|
164
171
|
arg_type = info.argument_type
|
165
|
-
tag = arg_type.tag
|
166
172
|
|
167
|
-
|
168
|
-
interface = info.argument_type.interface
|
173
|
+
val = gvalue_for_type_info arg_type
|
169
174
|
|
170
|
-
|
171
|
-
|
175
|
+
if arg_type.tag == :interface
|
176
|
+
interface = arg_type.interface
|
172
177
|
case interface.info_type
|
173
178
|
when :struct
|
174
179
|
val.set_boxed arg
|
@@ -179,30 +184,31 @@ module GirFFI
|
|
179
184
|
else
|
180
185
|
raise NotImplementedError, interface.info_type
|
181
186
|
end
|
182
|
-
|
183
|
-
return val
|
184
187
|
else
|
185
|
-
val = ::GObject::Value.new
|
186
|
-
val.init ::GObject.type_from_name(TAG_TYPE_TO_GTYPE_NAME_MAP[tag])
|
187
188
|
val.set_ruby_value arg
|
188
189
|
end
|
189
|
-
end
|
190
190
|
|
191
|
-
|
192
|
-
|
191
|
+
return val
|
192
|
+
end
|
193
193
|
|
194
|
-
|
195
|
-
|
194
|
+
def self.gvalue_for_type_info info
|
195
|
+
tag = info.tag
|
196
|
+
gtype = case tag
|
197
|
+
when :interface
|
198
|
+
info.interface.g_type
|
199
|
+
when :void
|
200
|
+
return nil
|
201
|
+
else
|
202
|
+
::GObject.type_from_name(TAG_TYPE_TO_GTYPE_NAME_MAP[tag])
|
203
|
+
end
|
204
|
+
::GObject::Value.new.tap {|val| val.init gtype}
|
205
|
+
end
|
196
206
|
|
197
|
-
|
198
|
-
|
207
|
+
def self.gvalue_for_signal_return_value signal, object
|
208
|
+
sig = object.class._find_signal signal
|
209
|
+
rettypeinfo = sig.return_type
|
199
210
|
|
200
|
-
|
201
|
-
if use_ret
|
202
|
-
rval = ::GObject::Value.new
|
203
|
-
rval.init query[:return_type]
|
204
|
-
end
|
205
|
-
rval
|
211
|
+
gvalue_for_type_info rettypeinfo
|
206
212
|
end
|
207
213
|
|
208
214
|
# TODO: Generate cast back methods using existing Argument builders.
|
data/lib/gir_ffi/version.rb
CHANGED
data/test/type_builder_test.rb
CHANGED
@@ -9,7 +9,7 @@ class TypeBuilderTest < MiniTest::Spec
|
|
9
9
|
stub(info = Object.new).parent { @gir.find_by_name 'GObject', 'Object' }
|
10
10
|
stub(info).fields { [] }
|
11
11
|
stub(info).info_type { :object }
|
12
|
-
stub(info).
|
12
|
+
stub(info).safe_name { 'Bar' }
|
13
13
|
stub(info).namespace { 'Foo' }
|
14
14
|
|
15
15
|
@classbuilder = GirFFI::Builder::Type::Object.new info
|
@@ -18,6 +18,38 @@ class TypeBuilderTest < MiniTest::Spec
|
|
18
18
|
assert_equal [:parent, GObject::Object::Struct, 0], spec
|
19
19
|
end
|
20
20
|
|
21
|
+
describe "for a layout with a fixed-length array" do
|
22
|
+
before do
|
23
|
+
stub(subtype = Object.new).pointer? { false }
|
24
|
+
stub(subtype).tag { :foo }
|
25
|
+
|
26
|
+
stub(@type = Object.new).pointer? { false }
|
27
|
+
stub(@type).tag { :array }
|
28
|
+
stub(@type).array_fixed_size { 2 }
|
29
|
+
stub(@type).param_type { subtype }
|
30
|
+
|
31
|
+
stub(field = Object.new).field_type { @type }
|
32
|
+
stub(field).name { "bar" }
|
33
|
+
stub(field).offset { 0 }
|
34
|
+
|
35
|
+
stub(@struct = Object.new).safe_name { 'Bar' }
|
36
|
+
stub(@struct).namespace { 'Foo' }
|
37
|
+
stub(@struct).fields { [ field ] }
|
38
|
+
end
|
39
|
+
|
40
|
+
it "creates the correct ffi type for the array" do
|
41
|
+
builder = GirFFI::Builder::Type::RegisteredType.new @struct
|
42
|
+
spec = builder.send :itypeinfo_to_ffitype_for_struct, @type
|
43
|
+
assert_equal [:foo, 2], spec
|
44
|
+
end
|
45
|
+
|
46
|
+
it "creates the correct layout specification" do
|
47
|
+
builder = GirFFI::Builder::Type::Struct.new @struct
|
48
|
+
spec = builder.send :layout_specification
|
49
|
+
assert_equal [:bar, [:foo, 2], 0], spec
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
21
53
|
context "for Gtk::Widget" do
|
22
54
|
setup do
|
23
55
|
@cbuilder = GirFFI::Builder::Type::Object.new get_introspection_data('Gtk', 'Widget')
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.expand_path('../test_helper.rb', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe GirFFI::IBaseInfo do
|
4
|
+
describe "#safe_name" do
|
5
|
+
it "makes names starting with an underscore safe" do
|
6
|
+
stub(ptr = Object.new).null? { false }
|
7
|
+
|
8
|
+
info = GirFFI::IBaseInfo.wrap ptr
|
9
|
+
|
10
|
+
stub(info).name { "_foo" }
|
11
|
+
|
12
|
+
assert_equal "Private___foo", info.safe_name
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gir_ffi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 14
|
10
|
+
version: 0.0.14
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matijs van Zuijlen
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-10-28 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: ffi
|
@@ -158,6 +158,7 @@ files:
|
|
158
158
|
- test/unit/i_repository_test.rb
|
159
159
|
- test/unit/constant_builder_test.rb
|
160
160
|
- test/unit/in_out_pointer_test.rb
|
161
|
+
- test/unit/i_base_info_test.rb
|
161
162
|
- test/unit/callback_helper_test.rb
|
162
163
|
- test/unit/builder_test.rb
|
163
164
|
- test/unit/in_pointer_test.rb
|
@@ -222,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
222
223
|
requirements: []
|
223
224
|
|
224
225
|
rubyforge_project:
|
225
|
-
rubygems_version: 1.
|
226
|
+
rubygems_version: 1.8.10
|
226
227
|
signing_key:
|
227
228
|
specification_version: 3
|
228
229
|
summary: FFI-based GObject binding using the GObject Introspection Repository
|
@@ -254,9 +255,9 @@ test_files:
|
|
254
255
|
- test/unit/builder_test.rb
|
255
256
|
- test/unit/callback_helper_test.rb
|
256
257
|
- test/unit/constant_builder_test.rb
|
258
|
+
- test/unit/i_base_info_test.rb
|
257
259
|
- test/unit/i_constant_info_test.rb
|
258
260
|
- test/unit/i_repository_test.rb
|
259
261
|
- test/unit/in_out_pointer_test.rb
|
260
262
|
- test/unit/in_pointer_test.rb
|
261
263
|
- test/unit/object_type_builder_test.rb
|
262
|
-
has_rdoc:
|