gir_ffi 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. data/History.txt +11 -0
  2. data/README.md +24 -6
  3. data/lib/ffi-glib/ptr_array.rb +17 -1
  4. data/lib/ffi-glib/variant.rb +15 -0
  5. data/lib/ffi-glib.rb +1 -0
  6. data/lib/ffi-gobject/object.rb +1 -1
  7. data/lib/ffi-gobject/ruby_closure.rb +1 -1
  8. data/lib/ffi-gobject/value.rb +13 -3
  9. data/lib/ffi-gobject.rb +1 -2
  10. data/lib/ffi-gobject_introspection/i_enum_info.rb +14 -0
  11. data/lib/ffi-gobject_introspection/lib.rb +2 -0
  12. data/lib/gir_ffi/arg_helper.rb +2 -0
  13. data/lib/gir_ffi/argument_builder.rb +22 -21
  14. data/lib/gir_ffi/base_argument_builder.rb +2 -1
  15. data/lib/gir_ffi/builder/module.rb +2 -3
  16. data/lib/gir_ffi/builder/type/enum.rb +18 -1
  17. data/lib/gir_ffi/builder/type/object.rb +20 -18
  18. data/lib/gir_ffi/class_base.rb +0 -1
  19. data/lib/gir_ffi/enum_base.rb +25 -0
  20. data/lib/gir_ffi/ffi_ext.rb +1 -0
  21. data/lib/gir_ffi/function_builder.rb +50 -33
  22. data/lib/gir_ffi/in_out_pointer.rb +0 -5
  23. data/lib/gir_ffi/in_pointer.rb +7 -5
  24. data/lib/gir_ffi/info_ext/i_callable_info.rb +4 -0
  25. data/lib/gir_ffi/info_ext/i_enum_info.rb +13 -0
  26. data/lib/gir_ffi/info_ext/i_field_info.rb +1 -1
  27. data/lib/gir_ffi/info_ext/i_object_info.rb +11 -0
  28. data/lib/gir_ffi/info_ext/i_registered_type_info.rb +11 -0
  29. data/lib/gir_ffi/info_ext/i_struct_info.rb +11 -0
  30. data/lib/gir_ffi/info_ext/i_type_info.rb +10 -19
  31. data/lib/gir_ffi/info_ext/i_union_info.rb +12 -0
  32. data/lib/gir_ffi/info_ext/safe_constant_name.rb +0 -2
  33. data/lib/gir_ffi/info_ext.rb +4 -0
  34. data/lib/gir_ffi/interface_base.rb +0 -1
  35. data/lib/gir_ffi/return_value_builder.rb +3 -2
  36. data/lib/gir_ffi/type_map.rb +3 -0
  37. data/lib/gir_ffi/version.rb +1 -1
  38. data/lib/gir_ffi/zero_terminated.rb +36 -3
  39. data/lib/gir_ffi-base/gir_ffi/library.rb +17 -0
  40. data/lib/gir_ffi-base/gobject/lib.rb +2 -2
  41. data/lib/gir_ffi.rb +1 -0
  42. data/tasks/test.rake +1 -0
  43. data/test/base_test_helper.rb +22 -2
  44. data/test/ffi-glib/ruby_closure_test.rb +1 -1
  45. data/test/ffi-glib/variant_test.rb +10 -0
  46. data/test/ffi-gobject/value_test.rb +24 -8
  47. data/test/ffi-gobject_introspection/i_enum_info_test.rb +17 -0
  48. data/test/gir_ffi/argument_builder_test.rb +66 -24
  49. data/test/gir_ffi/builder_test.rb +1 -1
  50. data/test/gir_ffi/function_builder_test.rb +1 -3
  51. data/test/gir_ffi/in_out_pointer_test.rb +5 -3
  52. data/test/gir_ffi/in_pointer_test.rb +32 -2
  53. data/test/gir_ffi/info_ext/i_arg_info_test.rb +2 -2
  54. data/test/gir_ffi/info_ext/i_callable_info_test.rb +2 -2
  55. data/test/gir_ffi/info_ext/i_field_info_test.rb +14 -20
  56. data/test/gir_ffi/info_ext/i_function_info_test.rb +2 -2
  57. data/test/gir_ffi/info_ext/i_signal_info_test.rb +2 -2
  58. data/test/gir_ffi/info_ext/i_type_info_test.rb +8 -8
  59. data/test/gir_ffi/info_ext/safe_constant_name_test.rb +2 -2
  60. data/test/gir_ffi/info_ext/safe_function_name_test.rb +2 -2
  61. data/test/gir_ffi/return_value_builder_test.rb +18 -1
  62. data/test/gir_ffi/zero_terminated_test.rb +10 -0
  63. data/test/gir_ffi_test_helper.rb +0 -19
  64. data/test/integration/generated_gimarshallingtests_test.rb +291 -99
  65. data/test/integration/generated_regress_test.rb +138 -14
  66. data/test/lib/autogen.sh +6 -2
  67. metadata +14 -2
@@ -10,6 +10,13 @@ end
10
10
 
11
11
  # Tests generated methods and functions in the Regress namespace.
12
12
  describe Regress do
13
+ describe Regress::Lib do
14
+ it "extends GirFFI::Library" do
15
+ class << Regress::Lib
16
+ self.must_be :include?, GirFFI::Library
17
+ end
18
+ end
19
+ end
13
20
  describe "Regress::ATestError" do
14
21
  before do
15
22
  skip unless get_introspection_data 'Regress', 'ATestError'
@@ -94,10 +101,25 @@ describe Regress do
94
101
  end
95
102
  end
96
103
 
104
+ it "has the constant MAXUINT64" do
105
+ skip unless get_introspection_data 'Regress', 'MAXUINT64'
106
+ Regress::MAXUINT64.must_equal 0xffff_ffff_ffff_ffff
107
+ end
108
+
109
+ it "has the constant MININT64" do
110
+ skip unless get_introspection_data 'Regress', 'MININT64'
111
+ Regress::MININT64.must_equal(-0x8000_0000_0000_0000)
112
+ end
113
+
97
114
  it "has the constant Mixed_Case_Constant" do
98
115
  assert_equal 4423, Regress::Mixed_Case_Constant
99
116
  end
100
117
 
118
+ it "has the constant NEGATIVE_INT_CONSTANT" do
119
+ skip unless get_introspection_data 'Regress', 'NEGATIVE_INT_CONSTANT'
120
+ Regress::NEGATIVE_INT_CONSTANT.must_equal(-42)
121
+ end
122
+
101
123
  it "has the constant STRING_CONSTANT" do
102
124
  assert_equal "Some String", Regress::STRING_CONSTANT
103
125
  end
@@ -120,7 +142,8 @@ describe Regress do
120
142
  end
121
143
 
122
144
  it "has a working function #quark" do
123
- skip
145
+ quark = Regress::TestABCError.quark
146
+ GLib.quark_to_string(quark).must_equal "regress-test-abc-error"
124
147
  end
125
148
  end
126
149
 
@@ -196,6 +219,24 @@ describe Regress do
196
219
  end
197
220
  end
198
221
 
222
+ describe "Regress::TestBoxedD" do
223
+ before do
224
+ skip unless get_introspection_data 'Regress', 'TestBoxedD'
225
+ end
226
+ it "creates an instance using #new" do
227
+ skip
228
+ end
229
+ it "has a working method #copy" do
230
+ skip
231
+ end
232
+ it "has a working method #free" do
233
+ skip
234
+ end
235
+ it "has a working method #get_magic" do
236
+ skip
237
+ end
238
+ end
239
+
199
240
  describe "Regress::TestDEFError" do
200
241
  before do
201
242
  skip unless get_introspection_data 'Regress', 'TestDEFError'
@@ -231,7 +272,14 @@ describe Regress do
231
272
  end
232
273
 
233
274
  it "has a working function #param" do
234
- skip
275
+ Regress::TestEnum.param(:value1).must_equal("value1")
276
+ Regress::TestEnum.param(:value2).must_equal("value2")
277
+ Regress::TestEnum.param(:value3).must_equal("value3")
278
+ Regress::TestEnum.param(:value4).must_equal("value4")
279
+ Regress::TestEnum.param(0).must_equal("value1")
280
+ Regress::TestEnum.param(1).must_equal("value2")
281
+ Regress::TestEnum.param(-1).must_equal("value3")
282
+ Regress::TestEnum.param(48).must_equal("value4")
235
283
  end
236
284
  end
237
285
 
@@ -278,7 +326,8 @@ describe Regress do
278
326
  end
279
327
 
280
328
  it "has a working function #quark" do
281
- skip
329
+ quark = Regress::TestError.quark
330
+ GLib.quark_to_string(quark).must_equal "regress-test-error"
282
331
  end
283
332
  end
284
333
 
@@ -321,13 +370,16 @@ describe Regress do
321
370
  GObject::Object
322
371
  end
323
372
 
324
- # TODO: Test more, if possible (e.g., cannot be instantiated).
373
+ it "cannot be instanciated" do
374
+ proc { Regress::TestFundamentalObject.new }.must_raise NoMethodError
375
+ end
325
376
 
326
377
  it "has a working method #ref" do
327
- skip
378
+ skip "Can only be tested in the descendent class"
328
379
  end
380
+
329
381
  it "has a working method #unref" do
330
- skip
382
+ skip "Can only be tested in the descendent class"
331
383
  end
332
384
  end
333
385
 
@@ -358,9 +410,21 @@ describe Regress do
358
410
  end
359
411
  end
360
412
 
413
+ # NOTE: The following tests test fields and methods on the abstract parent
414
+ # class.
361
415
  it "has a refcount of 1" do
362
416
  assert_equal 1, instance.refcount
363
417
  end
418
+
419
+ it "has a working method #ref" do
420
+ instance.ref
421
+ instance.refcount.must_equal 2
422
+ end
423
+
424
+ it "has a working method #unref" do
425
+ instance.unref
426
+ instance.refcount.must_equal 0
427
+ end
364
428
  end
365
429
 
366
430
  describe "Regress::TestInterface" do
@@ -668,29 +732,89 @@ describe Regress do
668
732
  end
669
733
 
670
734
  describe "Regress::TestOtherError" do
735
+ before do
736
+ skip unless get_introspection_data 'Regress', 'TestOtherError'
737
+ end
738
+
671
739
  it "has the member :code1" do
672
- skip
740
+ Regress::TestOtherError[:code1].must_equal 1
673
741
  end
742
+
674
743
  it "has the member :code2" do
675
- skip
744
+ Regress::TestOtherError[:code2].must_equal 2
676
745
  end
746
+
677
747
  it "has the member :code3" do
678
- skip
748
+ Regress::TestOtherError[:code3].must_equal 3
679
749
  end
750
+
680
751
  it "has a working function #quark" do
681
- skip
752
+ quark = Regress::TestOtherError.quark
753
+ GLib.quark_to_string(quark).must_equal "regress-test-other-error"
682
754
  end
683
755
  end
756
+
684
757
  describe "Regress::TestPrivateEnum" do
685
758
  it "has the member :public_enum_before" do
686
- skip
759
+ Regress::TestPrivateEnum[:public_enum_before].must_equal 1
760
+ end
761
+ it "does not have the member :private" do
762
+ Regress::TestPrivateEnum[:private].must_equal nil
687
763
  end
688
764
  it "has the member :public_enum_after" do
689
- skip
765
+ Regress::TestPrivateEnum[:public_enum_after].must_equal 4
690
766
  end
691
767
  end
768
+
692
769
  describe "Regress::TestPrivateStruct" do
770
+ let(:instance) { Regress::TestPrivateStruct.new }
771
+
772
+ it "has a writable field this_is_public_before" do
773
+ instance.this_is_public_before.must_equal 0
774
+ instance.this_is_public_before = 42
775
+ instance.this_is_public_before.must_equal 42
776
+ end
777
+
778
+ it "cannot read from field this_is_private" do
779
+ skip "GIR identifies this field as readable"
780
+ proc { instance.this_is_private }.must_raise NoMethodError
781
+ end
782
+
783
+ it "cannot write to field this_is_private" do
784
+ proc { instance.this_is_private = 42 }.must_raise NoMethodError
785
+ end
786
+
787
+ it "has a writable field this_is_public_after" do
788
+ instance.this_is_public_after.must_equal 0
789
+ instance.this_is_public_after = 42
790
+ instance.this_is_public_after.must_equal 42
791
+ end
693
792
  end
793
+
794
+ describe "Regress::TestReferenceEnum" do
795
+ before do
796
+ skip unless get_introspection_data 'Regress', 'TestReferenceEnum'
797
+ end
798
+ it "has the member :0" do
799
+ Regress::TestReferenceEnum[:"0"].must_equal 4
800
+ end
801
+ it "has the member :1" do
802
+ Regress::TestReferenceEnum[:"1"].must_equal 2
803
+ end
804
+ it "has the member :2" do
805
+ Regress::TestReferenceEnum[:"2"].must_equal 54
806
+ end
807
+ it "has the member :3" do
808
+ Regress::TestReferenceEnum[:"3"].must_equal 4
809
+ end
810
+ it "has the member :4" do
811
+ Regress::TestReferenceEnum[:"4"].must_equal 216
812
+ end
813
+ it "has the member :5" do
814
+ Regress::TestReferenceEnum[:"5"].must_equal(-217)
815
+ end
816
+ end
817
+
694
818
  describe "Regress::TestSimpleBoxedA" do
695
819
  it "creates an instance using #new" do
696
820
  obj = Regress::TestSimpleBoxedA.new
@@ -1172,7 +1296,7 @@ describe Regress do
1172
1296
 
1173
1297
  it "has a working function #test_date_in_gvalue" do
1174
1298
  r = Regress.test_date_in_gvalue
1175
- date = r.ruby_value
1299
+ date = r.get_value
1176
1300
  skip unless date.respond_to? :get_year
1177
1301
  assert_equal [1984, :december, 5],
1178
1302
  [date.get_year, date.get_month, date.get_day]
@@ -1506,7 +1630,7 @@ describe Regress do
1506
1630
 
1507
1631
  it "has a working function #test_strv_in_gvalue" do
1508
1632
  gv = Regress.test_strv_in_gvalue
1509
- assert_equal ['one', 'two', 'three'], gv.ruby_value.to_a
1633
+ assert_equal ['one', 'two', 'three'], gv.get_value.to_a
1510
1634
  end
1511
1635
 
1512
1636
  it "has a working function #test_strv_out" do
data/test/lib/autogen.sh CHANGED
@@ -41,7 +41,10 @@ if autoconf --version < /dev/null > /dev/null 2>&1 ; then : ; else
41
41
  DIE=1
42
42
  fi
43
43
 
44
- if automake-1.11 --version < /dev/null > /dev/null 2>&1 ; then
44
+ if automake-1.13 --version < /dev/null > /dev/null 2>&1 ; then
45
+ AUTOMAKE=automake-1.13
46
+ ACLOCAL=aclocal-1.13
47
+ else if automake-1.11 --version < /dev/null > /dev/null 2>&1 ; then
45
48
  AUTOMAKE=automake-1.11
46
49
  ACLOCAL=aclocal-1.11
47
50
  else if automake-1.10 --version < /dev/null > /dev/null 2>&1 ; then
@@ -49,12 +52,13 @@ else if automake-1.10 --version < /dev/null > /dev/null 2>&1 ; then
49
52
  ACLOCAL=aclocal-1.10
50
53
  else
51
54
  echo
52
- echo "You must have automake 1.10.x or 1.11.x installed to compile $PROJECT."
55
+ echo "You must have automake 1.13.x, 1.11.x or 1.10.x installed to compile $PROJECT."
53
56
  echo "Install the appropriate package for your distribution,"
54
57
  echo "or get the source tarball at http://ftp.gnu.org/gnu/automake/"
55
58
  DIE=1
56
59
  fi
57
60
  fi
61
+ fi
58
62
 
59
63
  if test "$DIE" -eq 1; then
60
64
  exit 1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gir_ffi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-15 00:00:00.000000000 Z
12
+ date: 2013-06-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
@@ -143,6 +143,7 @@ files:
143
143
  - lib/gir_ffi/arg_helper.rb
144
144
  - lib/gir_ffi/info_ext.rb
145
145
  - lib/gir_ffi/allocation_helper.rb
146
+ - lib/gir_ffi/ffi_ext.rb
146
147
  - lib/gir_ffi/type_map.rb
147
148
  - lib/gir_ffi/zero_terminated.rb
148
149
  - lib/gir_ffi/unintrospectable_type_info.rb
@@ -155,6 +156,7 @@ files:
155
156
  - lib/gir_ffi/builder_helper.rb
156
157
  - lib/gir_ffi/variable_name_generator.rb
157
158
  - lib/gir_ffi/in_pointer.rb
159
+ - lib/gir_ffi/enum_base.rb
158
160
  - lib/gir_ffi/return_value_builder.rb
159
161
  - lib/gir_ffi/in_out_pointer.rb
160
162
  - lib/gir_ffi/version.rb
@@ -162,6 +164,7 @@ files:
162
164
  - lib/gir_ffi/callback_helper.rb
163
165
  - lib/gir_ffi/builder.rb
164
166
  - lib/gir_ffi/interface_base.rb
167
+ - lib/gir_ffi/info_ext/i_struct_info.rb
165
168
  - lib/gir_ffi/info_ext/i_arg_info.rb
166
169
  - lib/gir_ffi/info_ext/i_type_info.rb
167
170
  - lib/gir_ffi/info_ext/i_function_info.rb
@@ -169,8 +172,11 @@ files:
169
172
  - lib/gir_ffi/info_ext/i_field_info.rb
170
173
  - lib/gir_ffi/info_ext/safe_constant_name.rb
171
174
  - lib/gir_ffi/info_ext/i_property_info.rb
175
+ - lib/gir_ffi/info_ext/i_enum_info.rb
172
176
  - lib/gir_ffi/info_ext/i_signal_info.rb
173
177
  - lib/gir_ffi/info_ext/safe_function_name.rb
178
+ - lib/gir_ffi/info_ext/i_union_info.rb
179
+ - lib/gir_ffi/info_ext/i_object_info.rb
174
180
  - lib/gir_ffi/info_ext/i_registered_type_info.rb
175
181
  - lib/gir_ffi/module_base.rb
176
182
  - lib/gir_ffi/base_argument_builder.rb
@@ -178,6 +184,7 @@ files:
178
184
  - lib/gir_ffi/class_base.rb
179
185
  - lib/gir_ffi/object_base.rb
180
186
  - lib/gir_ffi/function_builder.rb
187
+ - lib/gir_ffi-base/gir_ffi/library.rb
181
188
  - lib/gir_ffi-base/gobject/lib.rb
182
189
  - lib/gir_ffi-base/glib/strv.rb
183
190
  - lib/ffi-gobject/ruby_style.rb
@@ -196,6 +203,7 @@ files:
196
203
  - lib/ffi-glib/strv.rb
197
204
  - lib/ffi-glib/byte_array.rb
198
205
  - lib/ffi-glib/ptr_array.rb
206
+ - lib/ffi-glib/variant.rb
199
207
  - lib/ffi-glib/sized_array.rb
200
208
  - lib/ffi-glib/s_list.rb
201
209
  - lib/ffi-gobject_introspection/i_struct_info.rb
@@ -286,6 +294,7 @@ files:
286
294
  - test/ffi-glib/ptr_array_test.rb
287
295
  - test/ffi-glib/byte_array_test.rb
288
296
  - test/ffi-glib/ruby_closure_test.rb
297
+ - test/ffi-glib/variant_test.rb
289
298
  - test/ffi-glib/sized_array_test.rb
290
299
  - test/ffi-gobject_introspection/i_repository_test.rb
291
300
  - test/ffi-gobject_introspection/i_constant_info_test.rb
@@ -293,6 +302,7 @@ files:
293
302
  - test/ffi-gobject_introspection/i_object_info_test.rb
294
303
  - test/ffi-gobject_introspection/lib_test.rb
295
304
  - test/ffi-gobject_introspection/i_function_info_test.rb
305
+ - test/ffi-gobject_introspection/i_enum_info_test.rb
296
306
  - test/gir_ffi_test.rb
297
307
  - test/introspection_test_helper.rb
298
308
  - tasks/setup.rb
@@ -346,6 +356,7 @@ test_files:
346
356
  - test/ffi-glib/ruby_closure_test.rb
347
357
  - test/ffi-glib/s_list_test.rb
348
358
  - test/ffi-glib/sized_array_test.rb
359
+ - test/ffi-glib/variant_test.rb
349
360
  - test/ffi-gobject/gobject_test.rb
350
361
  - test/ffi-gobject/object_class_test.rb
351
362
  - test/ffi-gobject/object_test.rb
@@ -353,6 +364,7 @@ test_files:
353
364
  - test/ffi-gobject/value_test.rb
354
365
  - test/ffi-gobject_introspection/i_base_info_test.rb
355
366
  - test/ffi-gobject_introspection/i_constant_info_test.rb
367
+ - test/ffi-gobject_introspection/i_enum_info_test.rb
356
368
  - test/ffi-gobject_introspection/i_function_info_test.rb
357
369
  - test/ffi-gobject_introspection/i_object_info_test.rb
358
370
  - test/ffi-gobject_introspection/i_repository_test.rb