gir_ffi 0.8.3 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +9 -1
  3. data/Gemfile +1 -1
  4. data/README.md +3 -2
  5. data/lib/ffi-glib/bytes.rb +0 -14
  6. data/lib/ffi-glib/hash_table.rb +0 -1
  7. data/lib/ffi-gobject/object.rb +7 -0
  8. data/lib/ffi-gobject_introspection/i_base_info.rb +4 -0
  9. data/lib/ffi-gobject_introspection/lib.rb +1 -0
  10. data/lib/gir_ffi/boxed_base.rb +2 -2
  11. data/lib/gir_ffi/builders/callback_argument_builder.rb +3 -1
  12. data/lib/gir_ffi/builders/closure_return_value_builder.rb +0 -1
  13. data/lib/gir_ffi/builders/module_builder.rb +9 -2
  14. data/lib/gir_ffi/builders/null_class_builder.rb +1 -0
  15. data/lib/gir_ffi/builders/registered_type_builder.rb +5 -1
  16. data/lib/gir_ffi/callback_base.rb +2 -2
  17. data/lib/gir_ffi/enum_base.rb +2 -2
  18. data/lib/gir_ffi/in_out_pointer.rb +1 -1
  19. data/lib/gir_ffi/info_ext/i_registered_type_info.rb +1 -1
  20. data/lib/gir_ffi/object_base.rb +24 -8
  21. data/lib/gir_ffi/sized_array.rb +2 -2
  22. data/lib/gir_ffi/version.rb +1 -1
  23. data/lib/gir_ffi/zero_terminated.rb +12 -1
  24. data/lib/gir_ffi-base/glib/boolean.rb +2 -2
  25. data/tasks/test.rake +25 -23
  26. data/test/base_test_helper.rb +3 -4
  27. data/test/ffi-gobject/object_test.rb +10 -4
  28. data/test/ffi-gobject_introspection/i_property_info_test.rb +3 -2
  29. data/test/gir_ffi/builders/module_builder_test.rb +26 -3
  30. data/test/gir_ffi/object_base_test.rb +2 -2
  31. data/test/integration/generated_everything_test.rb +428 -0
  32. data/test/integration/generated_gimarshallingtests_test.rb +17 -0
  33. data/test/integration/generated_gtop_test.rb +21 -0
  34. data/test/integration/generated_regress_test.rb +734 -0
  35. data/test/integration/generated_warnlib_test.rb +47 -0
  36. data/test/introspection_test_helper.rb +2 -0
  37. data/test/lib/Makefile.am +82 -16
  38. data/test/lib/configure.ac +3 -0
  39. metadata +5 -2
@@ -0,0 +1,428 @@
1
+ require 'gir_ffi_test_helper'
2
+
3
+ GirFFI.setup :Everything
4
+
5
+ describe Everything do
6
+ it 'has a working function #const_return_GType' do
7
+ Everything.const_return_GType.must_equal GObject::TYPE_OBJECT
8
+ end
9
+
10
+ it 'has a working function #const_return_filename' do
11
+ Everything.const_return_filename.must_equal ''
12
+ end
13
+
14
+ it 'has a working function #const_return_gboolean' do
15
+ Everything.const_return_gboolean.must_equal false
16
+ end
17
+
18
+ it 'has a working function #const_return_gchar' do
19
+ Everything.const_return_gchar.must_equal 0
20
+ end
21
+
22
+ it 'has a working function #const_return_gdouble' do
23
+ Everything.const_return_gdouble.must_equal 0
24
+ end
25
+
26
+ it 'has a working function #const_return_gfloat' do
27
+ Everything.const_return_gfloat.must_equal 0
28
+ end
29
+
30
+ it 'has a working function #const_return_gint' do
31
+ Everything.const_return_gint.must_equal 0
32
+ end
33
+
34
+ it 'has a working function #const_return_gint16' do
35
+ Everything.const_return_gint16.must_equal 0
36
+ end
37
+
38
+ it 'has a working function #const_return_gint32' do
39
+ Everything.const_return_gint32.must_equal 0
40
+ end
41
+
42
+ it 'has a working function #const_return_gint64' do
43
+ Everything.const_return_gint64.must_equal 0
44
+ end
45
+
46
+ it 'has a working function #const_return_gint8' do
47
+ Everything.const_return_gint8.must_equal 0
48
+ end
49
+
50
+ it 'has a working function #const_return_gintptr' do
51
+ Everything.const_return_gintptr.must_equal 0
52
+ end
53
+
54
+ it 'has a working function #const_return_glong' do
55
+ Everything.const_return_glong.must_equal 0
56
+ end
57
+
58
+ it 'has a working function #const_return_gshort' do
59
+ Everything.const_return_gshort.must_equal 0
60
+ end
61
+
62
+ it 'has a working function #const_return_gsize' do
63
+ Everything.const_return_gsize.must_equal 0
64
+ end
65
+
66
+ it 'has a working function #const_return_gssize' do
67
+ Everything.const_return_gssize.must_equal 0
68
+ end
69
+
70
+ it 'has a working function #const_return_guint' do
71
+ Everything.const_return_guint.must_equal 0
72
+ end
73
+
74
+ it 'has a working function #const_return_guint16' do
75
+ Everything.const_return_guint16.must_equal 0
76
+ end
77
+
78
+ it 'has a working function #const_return_guint32' do
79
+ Everything.const_return_guint32.must_equal 0
80
+ end
81
+
82
+ it 'has a working function #const_return_guint64' do
83
+ Everything.const_return_guint64.must_equal 0
84
+ end
85
+
86
+ it 'has a working function #const_return_guint8' do
87
+ Everything.const_return_guint8.must_equal 0
88
+ end
89
+
90
+ it 'has a working function #const_return_guintptr' do
91
+ Everything.const_return_guintptr.must_equal 0
92
+ end
93
+
94
+ it 'has a working function #const_return_gulong' do
95
+ Everything.const_return_gulong.must_equal 0
96
+ end
97
+
98
+ it 'has a working function #const_return_gunichar' do
99
+ Everything.const_return_gunichar.must_equal 0
100
+ end
101
+
102
+ it 'has a working function #const_return_gushort' do
103
+ Everything.const_return_gushort.must_equal 0
104
+ end
105
+
106
+ it 'has a working function #const_return_utf8' do
107
+ Everything.const_return_utf8.must_equal ''
108
+ end
109
+
110
+ it 'has a working function #nullfunc' do
111
+ Everything.nullfunc.must_be_nil
112
+ end
113
+
114
+ it 'has a working function #one_outparam_GType' do
115
+ Everything.one_outparam_GType.must_equal 0
116
+ end
117
+
118
+ it 'has a working function #one_outparam_filename' do
119
+ # NOTE: This function stores a null pointer in its output parameter.
120
+ Everything.one_outparam_filename.must_be_nil
121
+ end
122
+
123
+ it 'has a working function #one_outparam_gboolean' do
124
+ Everything.one_outparam_gboolean.must_equal false
125
+ end
126
+
127
+ it 'has a working function #one_outparam_gchar' do
128
+ skip 'GIR gives the incorrect type: utf8 instead of gchar'
129
+ Everything.one_outparam_gchar.must_equal 0
130
+ end
131
+
132
+ it 'has a working function #one_outparam_gdouble' do
133
+ Everything.one_outparam_gdouble.must_equal 0
134
+ end
135
+
136
+ it 'has a working function #one_outparam_gfloat' do
137
+ Everything.one_outparam_gfloat.must_equal 0
138
+ end
139
+
140
+ it 'has a working function #one_outparam_gint' do
141
+ Everything.one_outparam_gint.must_equal 0
142
+ end
143
+
144
+ it 'has a working function #one_outparam_gint16' do
145
+ Everything.one_outparam_gint16.must_equal 0
146
+ end
147
+
148
+ it 'has a working function #one_outparam_gint32' do
149
+ Everything.one_outparam_gint32.must_equal 0
150
+ end
151
+
152
+ it 'has a working function #one_outparam_gint64' do
153
+ Everything.one_outparam_gint64.must_equal 0
154
+ end
155
+
156
+ it 'has a working function #one_outparam_gint8' do
157
+ Everything.one_outparam_gint8.must_equal 0
158
+ end
159
+
160
+ it 'has a working function #one_outparam_gintptr' do
161
+ Everything.one_outparam_gintptr.must_equal 0
162
+ end
163
+
164
+ it 'has a working function #one_outparam_glong' do
165
+ Everything.one_outparam_glong.must_equal 0
166
+ end
167
+
168
+ it 'has a working function #one_outparam_gshort' do
169
+ Everything.one_outparam_gshort.must_equal 0
170
+ end
171
+
172
+ it 'has a working function #one_outparam_gsize' do
173
+ Everything.one_outparam_gsize.must_equal 0
174
+ end
175
+
176
+ it 'has a working function #one_outparam_gssize' do
177
+ Everything.one_outparam_gssize.must_equal 0
178
+ end
179
+
180
+ it 'has a working function #one_outparam_guint' do
181
+ Everything.one_outparam_guint.must_equal 0
182
+ end
183
+
184
+ it 'has a working function #one_outparam_guint16' do
185
+ Everything.one_outparam_guint16.must_equal 0
186
+ end
187
+
188
+ it 'has a working function #one_outparam_guint32' do
189
+ Everything.one_outparam_guint32.must_equal 0
190
+ end
191
+
192
+ it 'has a working function #one_outparam_guint64' do
193
+ Everything.one_outparam_guint64.must_equal 0
194
+ end
195
+
196
+ it 'has a working function #one_outparam_guint8' do
197
+ Everything.one_outparam_guint8.must_equal 0
198
+ end
199
+
200
+ it 'has a working function #one_outparam_guintptr' do
201
+ Everything.one_outparam_guintptr.must_equal 0
202
+ end
203
+
204
+ it 'has a working function #one_outparam_gulong' do
205
+ Everything.one_outparam_gulong.must_equal 0
206
+ end
207
+
208
+ it 'has a working function #one_outparam_gunichar' do
209
+ Everything.one_outparam_gunichar.must_equal 0
210
+ end
211
+
212
+ it 'has a working function #one_outparam_gushort' do
213
+ Everything.one_outparam_gushort.must_equal 0
214
+ end
215
+
216
+ it 'has a working function #one_outparam_utf8' do
217
+ # NOTE: This function stores a null pointer in its output parameter.
218
+ Everything.one_outparam_utf8.must_be_nil
219
+ end
220
+
221
+ it 'has a working function #oneparam_GType' do
222
+ Everything.oneparam_GType(0).must_be_nil
223
+ end
224
+
225
+ it 'has a working function #oneparam_filename' do
226
+ Everything.oneparam_filename('').must_be_nil
227
+ end
228
+
229
+ it 'has a working function #oneparam_gboolean' do
230
+ Everything.oneparam_gboolean(false).must_be_nil
231
+ end
232
+
233
+ it 'has a working function #oneparam_gchar' do
234
+ Everything.oneparam_gchar(0).must_be_nil
235
+ end
236
+
237
+ it 'has a working function #oneparam_gdouble' do
238
+ Everything.oneparam_gdouble(0.0).must_be_nil
239
+ end
240
+
241
+ it 'has a working function #oneparam_gfloat' do
242
+ Everything.oneparam_gfloat(0.0).must_be_nil
243
+ end
244
+
245
+ it 'has a working function #oneparam_gint' do
246
+ Everything.oneparam_gint(0).must_be_nil
247
+ end
248
+
249
+ it 'has a working function #oneparam_gint16' do
250
+ Everything.oneparam_gint16(0).must_be_nil
251
+ end
252
+
253
+ it 'has a working function #oneparam_gint32' do
254
+ Everything.oneparam_gint32(0).must_be_nil
255
+ end
256
+
257
+ it 'has a working function #oneparam_gint64' do
258
+ Everything.oneparam_gint64(0).must_be_nil
259
+ end
260
+
261
+ it 'has a working function #oneparam_gint8' do
262
+ Everything.oneparam_gint8(0).must_be_nil
263
+ end
264
+
265
+ it 'has a working function #oneparam_gintptr' do
266
+ Everything.oneparam_gintptr(0).must_be_nil
267
+ end
268
+
269
+ it 'has a working function #oneparam_glong' do
270
+ Everything.oneparam_glong(0).must_be_nil
271
+ end
272
+
273
+ it 'has a working function #oneparam_gshort' do
274
+ Everything.oneparam_gshort(0).must_be_nil
275
+ end
276
+
277
+ it 'has a working function #oneparam_gsize' do
278
+ Everything.oneparam_gsize(0).must_be_nil
279
+ end
280
+
281
+ it 'has a working function #oneparam_gssize' do
282
+ Everything.oneparam_gssize(0).must_be_nil
283
+ end
284
+
285
+ it 'has a working function #oneparam_guint' do
286
+ Everything.oneparam_guint(0).must_be_nil
287
+ end
288
+
289
+ it 'has a working function #oneparam_guint16' do
290
+ Everything.oneparam_guint16(0).must_be_nil
291
+ end
292
+
293
+ it 'has a working function #oneparam_guint32' do
294
+ Everything.oneparam_guint32(0).must_be_nil
295
+ end
296
+
297
+ it 'has a working function #oneparam_guint64' do
298
+ Everything.oneparam_guint64(0).must_be_nil
299
+ end
300
+
301
+ it 'has a working function #oneparam_guint8' do
302
+ Everything.oneparam_guint8(0).must_be_nil
303
+ end
304
+
305
+ it 'has a working function #oneparam_guintptr' do
306
+ Everything.oneparam_guintptr(0).must_be_nil
307
+ end
308
+
309
+ it 'has a working function #oneparam_gulong' do
310
+ Everything.oneparam_gulong(0).must_be_nil
311
+ end
312
+
313
+ it 'has a working function #oneparam_gunichar' do
314
+ Everything.oneparam_gunichar(0).must_be_nil
315
+ end
316
+
317
+ it 'has a working function #oneparam_gushort' do
318
+ Everything.oneparam_gushort(0).must_be_nil
319
+ end
320
+
321
+ it 'has a working function #oneparam_utf8' do
322
+ Everything.oneparam_utf8('').must_be_nil
323
+ end
324
+
325
+ it 'has a working function #passthrough_one_GType' do
326
+ Everything.passthrough_one_GType(GObject::TYPE_OBJECT).must_equal GObject::TYPE_OBJECT
327
+ end
328
+
329
+ it 'has a working function #passthrough_one_filename' do
330
+ Everything.passthrough_one_filename('foo').must_equal 'foo'
331
+ end
332
+
333
+ it 'has a working function #passthrough_one_gboolean' do
334
+ Everything.passthrough_one_gboolean(true).must_equal true
335
+ end
336
+
337
+ it 'has a working function #passthrough_one_gchar' do
338
+ Everything.passthrough_one_gchar(42).must_equal 42
339
+ end
340
+
341
+ it 'has a working function #passthrough_one_gdouble' do
342
+ Everything.passthrough_one_gdouble(23.42).must_equal 23.42
343
+ end
344
+
345
+ it 'has a working function #passthrough_one_gfloat' do
346
+ Everything.passthrough_one_gfloat(23.42).must_be_close_to 23.42
347
+ end
348
+
349
+ it 'has a working function #passthrough_one_gint' do
350
+ Everything.passthrough_one_gint(42).must_equal 42
351
+ end
352
+
353
+ it 'has a working function #passthrough_one_gint16' do
354
+ Everything.passthrough_one_gint16(42).must_equal 42
355
+ end
356
+
357
+ it 'has a working function #passthrough_one_gint32' do
358
+ Everything.passthrough_one_gint32(42).must_equal 42
359
+ end
360
+
361
+ it 'has a working function #passthrough_one_gint64' do
362
+ Everything.passthrough_one_gint64(42).must_equal 42
363
+ end
364
+
365
+ it 'has a working function #passthrough_one_gint8' do
366
+ Everything.passthrough_one_gint8(42).must_equal 42
367
+ end
368
+
369
+ it 'has a working function #passthrough_one_gintptr' do
370
+ Everything.passthrough_one_gintptr(42).must_equal 42
371
+ end
372
+
373
+ it 'has a working function #passthrough_one_glong' do
374
+ Everything.passthrough_one_glong(42).must_equal 42
375
+ end
376
+
377
+ it 'has a working function #passthrough_one_gshort' do
378
+ Everything.passthrough_one_gshort(42).must_equal 42
379
+ end
380
+
381
+ it 'has a working function #passthrough_one_gsize' do
382
+ Everything.passthrough_one_gsize(42).must_equal 42
383
+ end
384
+
385
+ it 'has a working function #passthrough_one_gssize' do
386
+ Everything.passthrough_one_gssize(42).must_equal 42
387
+ end
388
+
389
+ it 'has a working function #passthrough_one_guint' do
390
+ Everything.passthrough_one_guint(42).must_equal 42
391
+ end
392
+
393
+ it 'has a working function #passthrough_one_guint16' do
394
+ Everything.passthrough_one_guint16(42).must_equal 42
395
+ end
396
+
397
+ it 'has a working function #passthrough_one_guint32' do
398
+ Everything.passthrough_one_guint32(42).must_equal 42
399
+ end
400
+
401
+ it 'has a working function #passthrough_one_guint64' do
402
+ Everything.passthrough_one_guint64(42).must_equal 42
403
+ end
404
+
405
+ it 'has a working function #passthrough_one_guint8' do
406
+ Everything.passthrough_one_guint8(42).must_equal 42
407
+ end
408
+
409
+ it 'has a working function #passthrough_one_guintptr' do
410
+ Everything.passthrough_one_guintptr(42).must_equal 42
411
+ end
412
+
413
+ it 'has a working function #passthrough_one_gulong' do
414
+ Everything.passthrough_one_gulong(42).must_equal 42
415
+ end
416
+
417
+ it 'has a working function #passthrough_one_gunichar' do
418
+ Everything.passthrough_one_gunichar(42).must_equal 42
419
+ end
420
+
421
+ it 'has a working function #passthrough_one_gushort' do
422
+ Everything.passthrough_one_gushort(42).must_equal 42
423
+ end
424
+
425
+ it 'has a working function #passthrough_one_utf8' do
426
+ Everything.passthrough_one_utf8('42').must_equal '42'
427
+ end
428
+ end
@@ -226,6 +226,18 @@ describe GIMarshallingTests do
226
226
  end
227
227
  end
228
228
 
229
+ describe 'GIMarshallingTests::InterfaceImpl' do
230
+ before do
231
+ skip unless get_introspection_data 'GIMarshallingTests', 'InterfaceImpl'
232
+ end
233
+
234
+ it 'has a working method #get_as_interface' do
235
+ obj = GIMarshallingTests::InterfaceImpl.new []
236
+ result = obj.get_as_interface
237
+ result.must_be_kind_of GIMarshallingTests::Interface
238
+ end
239
+ end
240
+
229
241
  describe 'GIMarshallingTests::NestedStruct' do
230
242
  let(:instance) { GIMarshallingTests::NestedStruct.new }
231
243
  it 'has a writable field simple_struct' do
@@ -278,6 +290,11 @@ describe GIMarshallingTests do
278
290
  assert_equal 42, ob.int
279
291
  end
280
292
 
293
+ it 'fails to create an instance using #new_fail' do
294
+ skip unless get_method_introspection_data('GIMarshallingTests', 'Object', 'new_fail')
295
+ proc { GIMarshallingTests::Object.new_fail 42 }.must_raise GirFFI::GLibError
296
+ end
297
+
281
298
  it 'has a working function #full_inout' do
282
299
  ob = GIMarshallingTests::Object.new 42
283
300
  ref_count(ob).must_equal 1
@@ -0,0 +1,21 @@
1
+ require 'gir_ffi_test_helper'
2
+
3
+ # Tests generated methods and functions in the GTop namespace. This namespace
4
+ # contains types with bad names, like 'glibtop_cpu'.
5
+ describe 'The generated GTop module' do
6
+ before do
7
+ GirFFI.setup :GTop
8
+ end
9
+
10
+ describe 'Glibtop' do
11
+ it 'is a valid struct class' do
12
+ GTop::Glibtop.ancestors.must_include GirFFI::StructBase
13
+ end
14
+
15
+ it 'can be created using Glibtop.init' do
16
+ skip unless get_method_introspection_data 'GTop', 'glibtop', 'init'
17
+ instance = GTop::Glibtop.init
18
+ instance.must_be_kind_of GTop::Glibtop
19
+ end
20
+ end
21
+ end