gir_ffi 0.2.3 → 0.3.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.
- data/History.txt +14 -0
- data/README.rdoc +3 -1
- data/examples/02_hello_world.rb +1 -0
- data/examples/03_upgraded_hello_world.rb +2 -1
- data/examples/05_notification.rb +2 -2
- data/examples/hard_coded.rb +31 -8
- data/lib/ffi-glib/array.rb +1 -1
- data/lib/ffi-glib/container_class_methods.rb +25 -0
- data/lib/ffi-glib/hash_table.rb +41 -38
- data/lib/ffi-glib/list.rb +15 -22
- data/lib/ffi-glib/list_methods.rb +16 -16
- data/lib/ffi-glib/ptr_array.rb +20 -15
- data/lib/ffi-glib/s_list.rb +15 -23
- data/lib/ffi-glib.rb +7 -0
- data/lib/ffi-gobject/base.rb +0 -13
- data/lib/ffi-gobject/object.rb +6 -0
- data/lib/ffi-gobject/ruby_style.rb +21 -0
- data/lib/ffi-gobject.rb +44 -0
- data/lib/ffi-gobject_introspection/i_object_info.rb +7 -0
- data/lib/ffi-gobject_introspection/lib.rb +1 -0
- data/lib/gir_ffi/arg_helper.rb +8 -6
- data/lib/gir_ffi/builder/argument.rb +1 -1
- data/lib/gir_ffi/builder/field.rb +6 -3
- data/lib/gir_ffi/builder/property.rb +28 -0
- data/lib/gir_ffi/builder/type/base.rb +6 -4
- data/lib/gir_ffi/builder/type/interface.rb +1 -0
- data/lib/gir_ffi/builder/type/object.rb +26 -1
- data/lib/gir_ffi/builder/type/registered_type.rb +9 -1
- data/lib/gir_ffi/builder/type/unintrospectable.rb +26 -8
- data/lib/gir_ffi/builder/type/user_defined.rb +119 -0
- data/lib/gir_ffi/builder/type/with_layout.rb +3 -3
- data/lib/gir_ffi/builder.rb +5 -0
- data/lib/gir_ffi/class_base.rb +6 -6
- data/lib/gir_ffi/info_ext/i_property_info.rb +12 -0
- data/lib/gir_ffi/info_ext/i_type_info.rb +4 -0
- data/lib/gir_ffi/user_defined/i_base_info.rb +7 -0
- data/lib/gir_ffi/user_defined/i_object_info.rb +13 -0
- data/lib/gir_ffi/user_defined/i_property_info.rb +9 -0
- data/lib/gir_ffi/user_defined/i_registered_type_info.rb +10 -0
- data/lib/gir_ffi/version.rb +1 -1
- data/lib/gir_ffi.rb +6 -0
- data/tasks/test.rake +12 -2
- data/test/builder_test.rb +0 -124
- data/test/ffi-glib/hash_table_test.rb +0 -14
- data/test/ffi-glib/list_test.rb +0 -13
- data/test/ffi-glib/ptr_array_test.rb +26 -8
- data/test/ffi-glib/s_list_test.rb +4 -4
- data/test/ffi-gobject/g_object_overrides_test.rb +16 -32
- data/test/ffi-gobject/gobject_test.rb +28 -1
- data/test/ffi-gobject/object_class_test.rb +21 -0
- data/test/ffi-gobject/object_test.rb +4 -0
- data/test/ffi-gobject/ruby_style_test.rb +38 -0
- data/test/ffi-gobject_introspection/i_constant_info_test.rb +5 -5
- data/test/ffi-gobject_introspection/i_repository_test.rb +4 -4
- data/test/ffi-gtk/gtk_test.rb +36 -0
- data/test/gir_ffi_test_helper.rb +8 -4
- data/test/integration/derived_classes_test.rb +34 -18
- data/test/integration/generated_gimarshallingtests_test.rb +20 -23
- data/test/integration/generated_gio_test.rb +5 -0
- data/test/integration/generated_gobject_test.rb +2 -2
- data/test/integration/generated_gtk_test.rb +1 -1
- data/test/integration/generated_pango_test.rb +20 -0
- data/test/integration/generated_regress_test.rb +1003 -955
- data/test/integration/pretty_print_test.rb +3 -1
- data/test/test_helper.rb +5 -0
- data/test/type_builder_test.rb +2 -19
- data/test/unit/arg_helper_test.rb +87 -1
- data/test/unit/builder_test.rb +113 -1
- data/test/unit/function_builder_test.rb +6 -5
- data/test/unit/gir_ffi_test.rb +69 -0
- data/test/unit/in_out_pointer_test.rb +3 -3
- data/test/unit/in_pointer_test.rb +1 -1
- data/test/unit/interface_builder_test.rb +16 -0
- data/test/unit/object_type_builder_test.rb +15 -0
- data/test/unit/struct_builder_test.rb +5 -1
- data/test/{unintrospectable_type_builder_test.rb → unit/unintrospectable_type_builder_test.rb} +18 -1
- data/test/unit/user_defined_object_info_test.rb +18 -0
- data/test/unit/user_defined_property_info_test.rb +14 -0
- data/test/unit/user_defined_registered_type_info_test.rb +10 -0
- data/test/unit/user_defined_type_builder_test.rb +41 -0
- metadata +34 -17
- data/tasks/notes.rake +0 -121
- data/tasks/rdoc.rake +0 -9
- data/tasks/yardoc.rake +0 -9
- data/test/arg_helper_test.rb +0 -33
- data/test/gtk_overrides_test.rb +0 -35
- data/test/interface_type_builder_test.rb +0 -17
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: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 2
|
9
8
|
- 3
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
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:
|
18
|
+
date: 2012-04-09 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: ffi
|
@@ -143,6 +143,7 @@ files:
|
|
143
143
|
- lib/ffi-glib/array.rb
|
144
144
|
- lib/ffi-glib/ptr_array.rb
|
145
145
|
- lib/ffi-glib/list.rb
|
146
|
+
- lib/ffi-glib/container_class_methods.rb
|
146
147
|
- lib/ffi-glib/list_methods.rb
|
147
148
|
- lib/ffi-glib/strv.rb
|
148
149
|
- lib/ffi-glib/hash_table.rb
|
@@ -156,6 +157,7 @@ files:
|
|
156
157
|
- lib/gir_ffi/builder/argument/in_base.rb
|
157
158
|
- lib/gir_ffi/builder/argument/out_base.rb
|
158
159
|
- lib/gir_ffi/builder/argument/in_out_base.rb
|
160
|
+
- lib/gir_ffi/builder/property.rb
|
159
161
|
- lib/gir_ffi/builder/module.rb
|
160
162
|
- lib/gir_ffi/builder/function.rb
|
161
163
|
- lib/gir_ffi/builder/type/with_methods.rb
|
@@ -170,6 +172,7 @@ files:
|
|
170
172
|
- lib/gir_ffi/builder/type/unintrospectable.rb
|
171
173
|
- lib/gir_ffi/builder/type/with_layout.rb
|
172
174
|
- lib/gir_ffi/builder/type/union.rb
|
175
|
+
- lib/gir_ffi/builder/type/user_defined.rb
|
173
176
|
- lib/gir_ffi/builder/type/object.rb
|
174
177
|
- lib/gir_ffi/builder/type.rb
|
175
178
|
- lib/gir_ffi/builder/field.rb
|
@@ -179,15 +182,21 @@ files:
|
|
179
182
|
- lib/gir_ffi/class_base.rb
|
180
183
|
- lib/gir_ffi/callback_helper.rb
|
181
184
|
- lib/gir_ffi/in_pointer.rb
|
185
|
+
- lib/gir_ffi/user_defined/i_object_info.rb
|
186
|
+
- lib/gir_ffi/user_defined/i_property_info.rb
|
187
|
+
- lib/gir_ffi/user_defined/i_registered_type_info.rb
|
188
|
+
- lib/gir_ffi/user_defined/i_base_info.rb
|
182
189
|
- lib/gir_ffi/variable_name_generator.rb
|
183
190
|
- lib/gir_ffi/version.rb
|
184
191
|
- lib/gir_ffi/info_ext/i_field_info.rb
|
192
|
+
- lib/gir_ffi/info_ext/i_property_info.rb
|
185
193
|
- lib/gir_ffi/info_ext/i_type_info.rb
|
186
194
|
- lib/gir_ffi/allocation_helper.rb
|
187
195
|
- lib/gir_ffi/ffi_ext/pointer.rb
|
188
196
|
- lib/gir_ffi/method_stubber.rb
|
189
197
|
- lib/gir_ffi/arg_helper.rb
|
190
198
|
- lib/gir_ffi/type_map.rb
|
199
|
+
- lib/ffi-gobject/ruby_style.rb
|
191
200
|
- lib/ffi-gobject/ruby_closure.rb
|
192
201
|
- lib/ffi-gobject/base.rb
|
193
202
|
- lib/ffi-gobject/value.rb
|
@@ -195,13 +204,12 @@ files:
|
|
195
204
|
- lib/ffi-gobject/initially_unowned.rb
|
196
205
|
- lib/ffi-gobject/helper.rb
|
197
206
|
- lib/ffi-gobject/object.rb
|
198
|
-
- test/unintrospectable_type_builder_test.rb
|
199
207
|
- test/gir_ffi_test_helper.rb
|
200
|
-
- test/arg_helper_test.rb
|
201
208
|
- test/lib/Makefile.am
|
202
209
|
- test/lib/autogen.sh
|
203
210
|
- test/lib/configure.ac
|
204
211
|
- test/lib/m4/jhflags.m4
|
212
|
+
- test/ffi-gtk/gtk_test.rb
|
205
213
|
- test/ffi-gobject_introspection/i_repository_test.rb
|
206
214
|
- test/ffi-gobject_introspection/i_object_info_test.rb
|
207
215
|
- test/ffi-gobject_introspection/i_base_info_test.rb
|
@@ -210,12 +218,15 @@ files:
|
|
210
218
|
- test/ffi-gobject_introspection/i_constant_info_test.rb
|
211
219
|
- test/test_helper.rb
|
212
220
|
- test/girffi_test.rb
|
213
|
-
- test/
|
221
|
+
- test/unit/user_defined_object_info_test.rb
|
214
222
|
- test/unit/union_builder_test.rb
|
223
|
+
- test/unit/unintrospectable_type_builder_test.rb
|
215
224
|
- test/unit/argument_builder_test.rb
|
225
|
+
- test/unit/user_defined_property_info_test.rb
|
216
226
|
- test/unit/callback_builder_test.rb
|
217
227
|
- test/unit/arg_helper_test.rb
|
218
228
|
- test/unit/i_type_info_test.rb
|
229
|
+
- test/unit/user_defined_registered_type_info_test.rb
|
219
230
|
- test/unit/constant_builder_test.rb
|
220
231
|
- test/unit/class_base_test.rb
|
221
232
|
- test/unit/function_builder_test.rb
|
@@ -228,15 +239,17 @@ files:
|
|
228
239
|
- test/unit/builder_test.rb
|
229
240
|
- test/unit/in_pointer_test.rb
|
230
241
|
- test/unit/enum_builder_test.rb
|
242
|
+
- test/unit/gir_ffi_test.rb
|
231
243
|
- test/unit/i_field_info_test.rb
|
232
244
|
- test/unit/struct_builder_test.rb
|
233
245
|
- test/unit/object_type_builder_test.rb
|
246
|
+
- test/unit/user_defined_type_builder_test.rb
|
234
247
|
- test/unit/variable_name_generator_test.rb
|
235
248
|
- test/type_builder_test.rb
|
236
249
|
- test/builder_test.rb
|
237
|
-
- test/gtk_overrides_test.rb
|
238
250
|
- test/integration/generated_regress_test.rb
|
239
251
|
- test/integration/pretty_print_test.rb
|
252
|
+
- test/integration/generated_pango_test.rb
|
240
253
|
- test/integration/derived_classes_test.rb
|
241
254
|
- test/integration/method_lookup_test.rb
|
242
255
|
- test/integration/generated_gtk_test.rb
|
@@ -252,14 +265,13 @@ files:
|
|
252
265
|
- test/ffi-glib/list_test.rb
|
253
266
|
- test/ffi-glib/ptr_array_test.rb
|
254
267
|
- test/ffi-gobject/gobject_test.rb
|
268
|
+
- test/ffi-gobject/object_class_test.rb
|
255
269
|
- test/ffi-gobject/g_object_overrides_test.rb
|
270
|
+
- test/ffi-gobject/ruby_style_test.rb
|
256
271
|
- test/ffi-gobject/object_test.rb
|
257
272
|
- test/ffi-gobject/value_test.rb
|
258
|
-
- tasks/yardoc.rake
|
259
|
-
- tasks/rdoc.rake
|
260
273
|
- tasks/test.rake
|
261
274
|
- tasks/setup.rb
|
262
|
-
- tasks/notes.rake
|
263
275
|
- examples/print_class.rb
|
264
276
|
- examples/05_notification.rb
|
265
277
|
- examples/demo_ffi_safe_inherited_layout.rb
|
@@ -305,12 +317,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
305
317
|
requirements: []
|
306
318
|
|
307
319
|
rubyforge_project:
|
308
|
-
rubygems_version: 1.8.
|
320
|
+
rubygems_version: 1.8.15
|
309
321
|
signing_key:
|
310
322
|
specification_version: 3
|
311
323
|
summary: FFI-based GObject binding using the GObject Introspection Repository
|
312
324
|
test_files:
|
313
|
-
- test/arg_helper_test.rb
|
314
325
|
- test/builder_test.rb
|
315
326
|
- test/ffi-glib/array_test.rb
|
316
327
|
- test/ffi-glib/byte_array_test.rb
|
@@ -322,7 +333,9 @@ test_files:
|
|
322
333
|
- test/ffi-glib/strv_test.rb
|
323
334
|
- test/ffi-gobject/g_object_overrides_test.rb
|
324
335
|
- test/ffi-gobject/gobject_test.rb
|
336
|
+
- test/ffi-gobject/object_class_test.rb
|
325
337
|
- test/ffi-gobject/object_test.rb
|
338
|
+
- test/ffi-gobject/ruby_style_test.rb
|
326
339
|
- test/ffi-gobject/value_test.rb
|
327
340
|
- test/ffi-gobject_introspection/i_base_info_test.rb
|
328
341
|
- test/ffi-gobject_introspection/i_constant_info_test.rb
|
@@ -330,25 +343,24 @@ test_files:
|
|
330
343
|
- test/ffi-gobject_introspection/i_object_info_test.rb
|
331
344
|
- test/ffi-gobject_introspection/i_repository_test.rb
|
332
345
|
- test/ffi-gobject_introspection/lib_test.rb
|
346
|
+
- test/ffi-gtk/gtk_test.rb
|
333
347
|
- test/gir_ffi_test_helper.rb
|
334
348
|
- test/girffi_test.rb
|
335
|
-
- test/gtk_overrides_test.rb
|
336
349
|
- test/integration/derived_classes_test.rb
|
337
350
|
- test/integration/generated_gimarshallingtests_test.rb
|
338
351
|
- test/integration/generated_gio_test.rb
|
339
352
|
- test/integration/generated_gobject_test.rb
|
340
353
|
- test/integration/generated_gtk_test.rb
|
354
|
+
- test/integration/generated_pango_test.rb
|
341
355
|
- test/integration/generated_regress_test.rb
|
342
356
|
- test/integration/method_lookup_test.rb
|
343
357
|
- test/integration/pretty_print_test.rb
|
344
|
-
- test/interface_type_builder_test.rb
|
345
358
|
- test/lib/Makefile.am
|
346
359
|
- test/lib/autogen.sh
|
347
360
|
- test/lib/configure.ac
|
348
361
|
- test/lib/m4/jhflags.m4
|
349
362
|
- test/test_helper.rb
|
350
363
|
- test/type_builder_test.rb
|
351
|
-
- test/unintrospectable_type_builder_test.rb
|
352
364
|
- test/unit/arg_helper_test.rb
|
353
365
|
- test/unit/argument_builder_test.rb
|
354
366
|
- test/unit/builder_test.rb
|
@@ -358,6 +370,7 @@ test_files:
|
|
358
370
|
- test/unit/constant_builder_test.rb
|
359
371
|
- test/unit/enum_builder_test.rb
|
360
372
|
- test/unit/function_builder_test.rb
|
373
|
+
- test/unit/gir_ffi_test.rb
|
361
374
|
- test/unit/hash_table_element_type_provider_test.rb
|
362
375
|
- test/unit/i_field_info_test.rb
|
363
376
|
- test/unit/i_type_info_test.rb
|
@@ -368,6 +381,10 @@ test_files:
|
|
368
381
|
- test/unit/module_builder_test.rb
|
369
382
|
- test/unit/object_type_builder_test.rb
|
370
383
|
- test/unit/struct_builder_test.rb
|
384
|
+
- test/unit/unintrospectable_type_builder_test.rb
|
371
385
|
- test/unit/union_builder_test.rb
|
386
|
+
- test/unit/user_defined_object_info_test.rb
|
387
|
+
- test/unit/user_defined_property_info_test.rb
|
388
|
+
- test/unit/user_defined_registered_type_info_test.rb
|
389
|
+
- test/unit/user_defined_type_builder_test.rb
|
372
390
|
- test/unit/variable_name_generator_test.rb
|
373
|
-
has_rdoc:
|
data/tasks/notes.rake
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
# The following code is copied straight from Bones 2.5.1
|
2
|
-
#
|
3
|
-
|
4
|
-
module Bones
|
5
|
-
|
6
|
-
# A helper class used to find and display any annotations in a collection of
|
7
|
-
# project files.
|
8
|
-
#
|
9
|
-
class AnnotationExtractor
|
10
|
-
|
11
|
-
class Annotation < Struct.new(:line, :tag, :text)
|
12
|
-
# Returns a string representation of the annotation. If the
|
13
|
-
# <tt>:tag</tt> parameter is given as +true+, then the annotation tag
|
14
|
-
# will be included in the string.
|
15
|
-
#
|
16
|
-
def to_s( opts = {} )
|
17
|
-
s = "[%3d] " % line
|
18
|
-
s << "[#{tag}] " if opts[:tag]
|
19
|
-
s << text
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
# Enumerate all the annoations for the given _project_ and _tag_. This
|
24
|
-
# will search for all athe annotations and display them on standard
|
25
|
-
# output.
|
26
|
-
#
|
27
|
-
def self.enumerate tag, id = nil, opts = {}
|
28
|
-
extractor = new(tag, id)
|
29
|
-
extractor.display(extractor.find, opts)
|
30
|
-
end
|
31
|
-
|
32
|
-
attr_reader :tag, :id
|
33
|
-
|
34
|
-
# Creates a new annotation extractor configured to use the _project_ open
|
35
|
-
# strcut and to search for the given _tag_ (which can be more than one tag
|
36
|
-
# via a regular expression 'or' operation -- i.e. THIS|THAT|OTHER)
|
37
|
-
#
|
38
|
-
def initialize tag, id
|
39
|
-
@tag = tag
|
40
|
-
@id = @id_rgxp = nil
|
41
|
-
|
42
|
-
unless id.nil? or id.empty?
|
43
|
-
@id = id
|
44
|
-
@id_rgxp = Regexp.new(Regexp.escape(id), Regexp::IGNORECASE)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
# Iterate over all the files in the project and extract annotations from
|
49
|
-
# the those files. Returns the results as a hash for display.
|
50
|
-
#
|
51
|
-
def find
|
52
|
-
results = {}
|
53
|
-
rgxp = %r/(#{tag}):?\s*(.*?)(?:\s*(?:-?%>|\*+\/))?$/o
|
54
|
-
|
55
|
-
files = Dir.glob("lib/**/*.rb")
|
56
|
-
files += Dir.glob("test/**/*.rb")
|
57
|
-
files.each do |fn|
|
58
|
-
results.update(extract_annotations_from(fn, rgxp))
|
59
|
-
end
|
60
|
-
|
61
|
-
results
|
62
|
-
end
|
63
|
-
|
64
|
-
# Extract any annotations from the given _file_ using the regular
|
65
|
-
# expression _pattern_ provided.
|
66
|
-
#
|
67
|
-
def extract_annotations_from( file, pattern )
|
68
|
-
lineno = 0
|
69
|
-
result = File.readlines(file).inject([]) do |list, line|
|
70
|
-
lineno += 1
|
71
|
-
next list unless m = pattern.match(line)
|
72
|
-
next list << Annotation.new(lineno, m[1], m[2]) unless id
|
73
|
-
|
74
|
-
text = m[2]
|
75
|
-
if text =~ @id_rgxp
|
76
|
-
list << Annotation.new(lineno, m[1], text)
|
77
|
-
end
|
78
|
-
list
|
79
|
-
end
|
80
|
-
result.empty? ? {} : { file => result }
|
81
|
-
end
|
82
|
-
|
83
|
-
# Print the results of the annotation extraction to the screen. If the
|
84
|
-
# <tt>:tags</tt> option is set to +true+, then the annotation tag will be
|
85
|
-
# displayed.
|
86
|
-
#
|
87
|
-
def display( results, opts = {} )
|
88
|
-
results.keys.sort.each do |file|
|
89
|
-
puts "#{file}:"
|
90
|
-
results[file].each do |note|
|
91
|
-
puts " * #{note.to_s(opts)}"
|
92
|
-
end
|
93
|
-
puts
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
end # class AnnotationExtractor
|
98
|
-
end # module Bones
|
99
|
-
|
100
|
-
note_tags = ["TODO", "FIXME", "OPTIMIZE"]
|
101
|
-
|
102
|
-
desc "Enumerate all annotations"
|
103
|
-
task :notes do |t|
|
104
|
-
id = if t.application.top_level_tasks.length > 1
|
105
|
-
t.application.top_level_tasks.slice!(1..-1).join(' ')
|
106
|
-
end
|
107
|
-
Bones::AnnotationExtractor.enumerate(
|
108
|
-
note_tags.join('|'), id, :tag => true)
|
109
|
-
end
|
110
|
-
|
111
|
-
namespace :notes do
|
112
|
-
note_tags.each do |tag|
|
113
|
-
desc "Enumerate all #{tag} annotations"
|
114
|
-
task tag.downcase.to_sym do |t|
|
115
|
-
id = if t.application.top_level_tasks.length > 1
|
116
|
-
t.application.top_level_tasks.slice!(1..-1).join(' ')
|
117
|
-
end
|
118
|
-
Bones::AnnotationExtractor.enumerate(tag, id)
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
data/tasks/rdoc.rake
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require "rdoc/task"
|
3
|
-
|
4
|
-
RDoc::Task.new(:rdoc => "rdoc", :clobber_rdoc => "rdoc:clean", :rerdoc => "rdoc:force") do |rdoc|
|
5
|
-
rdoc.main = "README.rdoc"
|
6
|
-
rdoc.rdoc_files.include "README.rdoc", "DESIGN.rdoc", "TODO.rdoc", "lib/**/*.rb"
|
7
|
-
end
|
8
|
-
rescue LoadError
|
9
|
-
end
|
data/tasks/yardoc.rake
DELETED
data/test/arg_helper_test.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require File.expand_path('gir_ffi_test_helper.rb', File.dirname(__FILE__))
|
2
|
-
|
3
|
-
class ArgHelperTest < MiniTest::Spec
|
4
|
-
context "The object_to_inptr method" do
|
5
|
-
context "when called with an object implementing to_ptr" do
|
6
|
-
should "return the result of to_ptr" do
|
7
|
-
obj = Object.new
|
8
|
-
def obj.to_ptr; :test_value; end
|
9
|
-
assert_equal :test_value, GirFFI::ArgHelper.object_to_inptr(obj)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
context "when called with nil" do
|
14
|
-
should "return nil" do
|
15
|
-
assert_equal nil, GirFFI::ArgHelper.object_to_inptr(nil)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "::object_pointer_to_object" do
|
21
|
-
it "finds the wrapping class by gtype and wraps the pointer in it" do
|
22
|
-
klsptr = GirFFI::InOutPointer.from :gtype, 0xdeadbeef
|
23
|
-
objptr = GirFFI::InOutPointer.from :pointer, klsptr
|
24
|
-
|
25
|
-
object_class = Class.new
|
26
|
-
mock(GirFFI::Builder).build_by_gtype(0xdeadbeef) { object_class }
|
27
|
-
mock(object_class).wrap(objptr) { "good-result" }
|
28
|
-
|
29
|
-
r = GirFFI::ArgHelper.object_pointer_to_object objptr
|
30
|
-
assert_equal "good-result", r
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/test/gtk_overrides_test.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require File.expand_path('gir_ffi_test_helper.rb', File.dirname(__FILE__))
|
2
|
-
|
3
|
-
describe "Gtk's overrides" do
|
4
|
-
before do
|
5
|
-
save_module :Gtk
|
6
|
-
::Object.const_set :Gtk, Module.new
|
7
|
-
Gtk.class_eval do
|
8
|
-
def self.init arr
|
9
|
-
["baz", "qux", "zonk"]
|
10
|
-
end
|
11
|
-
end
|
12
|
-
stub(Gtk)._setup_method { }
|
13
|
-
|
14
|
-
load 'ffi-gtk/base.rb'
|
15
|
-
end
|
16
|
-
|
17
|
-
context "The .init function" do
|
18
|
-
should "not take any arguments" do
|
19
|
-
assert_raises(ArgumentError) { Gtk.init 1, ["foo"] }
|
20
|
-
assert_raises(ArgumentError) { Gtk.init ["foo"] }
|
21
|
-
assert_nothing_raised { Gtk.init }
|
22
|
-
end
|
23
|
-
|
24
|
-
should "replace ARGV with the tail of the result of the original init function" do
|
25
|
-
ARGV.replace ["foo", "bar"]
|
26
|
-
Gtk.init
|
27
|
-
assert_equal ["qux", "zonk"], ARGV.to_a
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
after do
|
32
|
-
restore_module :Gtk
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require File.expand_path('gir_ffi_test_helper.rb', File.dirname(__FILE__))
|
2
|
-
|
3
|
-
describe GirFFI::Builder::Type::Interface do
|
4
|
-
before do
|
5
|
-
info = get_introspection_data 'GObject', 'TypePlugin'
|
6
|
-
@bldr = GirFFI::Builder::Type::Interface.new info
|
7
|
-
@iface = @bldr.build_class
|
8
|
-
end
|
9
|
-
|
10
|
-
it "builds an interface as a module" do
|
11
|
-
assert_instance_of Module, @iface
|
12
|
-
end
|
13
|
-
|
14
|
-
it "creates methods on the interface" do
|
15
|
-
assert_defines_instance_method @iface, :complete_interface_info
|
16
|
-
end
|
17
|
-
end
|