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.
Files changed (87) hide show
  1. data/History.txt +14 -0
  2. data/README.rdoc +3 -1
  3. data/examples/02_hello_world.rb +1 -0
  4. data/examples/03_upgraded_hello_world.rb +2 -1
  5. data/examples/05_notification.rb +2 -2
  6. data/examples/hard_coded.rb +31 -8
  7. data/lib/ffi-glib/array.rb +1 -1
  8. data/lib/ffi-glib/container_class_methods.rb +25 -0
  9. data/lib/ffi-glib/hash_table.rb +41 -38
  10. data/lib/ffi-glib/list.rb +15 -22
  11. data/lib/ffi-glib/list_methods.rb +16 -16
  12. data/lib/ffi-glib/ptr_array.rb +20 -15
  13. data/lib/ffi-glib/s_list.rb +15 -23
  14. data/lib/ffi-glib.rb +7 -0
  15. data/lib/ffi-gobject/base.rb +0 -13
  16. data/lib/ffi-gobject/object.rb +6 -0
  17. data/lib/ffi-gobject/ruby_style.rb +21 -0
  18. data/lib/ffi-gobject.rb +44 -0
  19. data/lib/ffi-gobject_introspection/i_object_info.rb +7 -0
  20. data/lib/ffi-gobject_introspection/lib.rb +1 -0
  21. data/lib/gir_ffi/arg_helper.rb +8 -6
  22. data/lib/gir_ffi/builder/argument.rb +1 -1
  23. data/lib/gir_ffi/builder/field.rb +6 -3
  24. data/lib/gir_ffi/builder/property.rb +28 -0
  25. data/lib/gir_ffi/builder/type/base.rb +6 -4
  26. data/lib/gir_ffi/builder/type/interface.rb +1 -0
  27. data/lib/gir_ffi/builder/type/object.rb +26 -1
  28. data/lib/gir_ffi/builder/type/registered_type.rb +9 -1
  29. data/lib/gir_ffi/builder/type/unintrospectable.rb +26 -8
  30. data/lib/gir_ffi/builder/type/user_defined.rb +119 -0
  31. data/lib/gir_ffi/builder/type/with_layout.rb +3 -3
  32. data/lib/gir_ffi/builder.rb +5 -0
  33. data/lib/gir_ffi/class_base.rb +6 -6
  34. data/lib/gir_ffi/info_ext/i_property_info.rb +12 -0
  35. data/lib/gir_ffi/info_ext/i_type_info.rb +4 -0
  36. data/lib/gir_ffi/user_defined/i_base_info.rb +7 -0
  37. data/lib/gir_ffi/user_defined/i_object_info.rb +13 -0
  38. data/lib/gir_ffi/user_defined/i_property_info.rb +9 -0
  39. data/lib/gir_ffi/user_defined/i_registered_type_info.rb +10 -0
  40. data/lib/gir_ffi/version.rb +1 -1
  41. data/lib/gir_ffi.rb +6 -0
  42. data/tasks/test.rake +12 -2
  43. data/test/builder_test.rb +0 -124
  44. data/test/ffi-glib/hash_table_test.rb +0 -14
  45. data/test/ffi-glib/list_test.rb +0 -13
  46. data/test/ffi-glib/ptr_array_test.rb +26 -8
  47. data/test/ffi-glib/s_list_test.rb +4 -4
  48. data/test/ffi-gobject/g_object_overrides_test.rb +16 -32
  49. data/test/ffi-gobject/gobject_test.rb +28 -1
  50. data/test/ffi-gobject/object_class_test.rb +21 -0
  51. data/test/ffi-gobject/object_test.rb +4 -0
  52. data/test/ffi-gobject/ruby_style_test.rb +38 -0
  53. data/test/ffi-gobject_introspection/i_constant_info_test.rb +5 -5
  54. data/test/ffi-gobject_introspection/i_repository_test.rb +4 -4
  55. data/test/ffi-gtk/gtk_test.rb +36 -0
  56. data/test/gir_ffi_test_helper.rb +8 -4
  57. data/test/integration/derived_classes_test.rb +34 -18
  58. data/test/integration/generated_gimarshallingtests_test.rb +20 -23
  59. data/test/integration/generated_gio_test.rb +5 -0
  60. data/test/integration/generated_gobject_test.rb +2 -2
  61. data/test/integration/generated_gtk_test.rb +1 -1
  62. data/test/integration/generated_pango_test.rb +20 -0
  63. data/test/integration/generated_regress_test.rb +1003 -955
  64. data/test/integration/pretty_print_test.rb +3 -1
  65. data/test/test_helper.rb +5 -0
  66. data/test/type_builder_test.rb +2 -19
  67. data/test/unit/arg_helper_test.rb +87 -1
  68. data/test/unit/builder_test.rb +113 -1
  69. data/test/unit/function_builder_test.rb +6 -5
  70. data/test/unit/gir_ffi_test.rb +69 -0
  71. data/test/unit/in_out_pointer_test.rb +3 -3
  72. data/test/unit/in_pointer_test.rb +1 -1
  73. data/test/unit/interface_builder_test.rb +16 -0
  74. data/test/unit/object_type_builder_test.rb +15 -0
  75. data/test/unit/struct_builder_test.rb +5 -1
  76. data/test/{unintrospectable_type_builder_test.rb → unit/unintrospectable_type_builder_test.rb} +18 -1
  77. data/test/unit/user_defined_object_info_test.rb +18 -0
  78. data/test/unit/user_defined_property_info_test.rb +14 -0
  79. data/test/unit/user_defined_registered_type_info_test.rb +10 -0
  80. data/test/unit/user_defined_type_builder_test.rb +41 -0
  81. metadata +34 -17
  82. data/tasks/notes.rake +0 -121
  83. data/tasks/rdoc.rake +0 -9
  84. data/tasks/yardoc.rake +0 -9
  85. data/test/arg_helper_test.rb +0 -33
  86. data/test/gtk_overrides_test.rb +0 -35
  87. data/test/interface_type_builder_test.rb +0 -17
@@ -38,20 +38,24 @@ describe "GIMarshallingTests" do
38
38
  end
39
39
 
40
40
  it "has a working function #inout" do
41
+ skip unless get_method_introspection_data 'GIMarshallingTests', 'BoxedStruct', 'inout'
41
42
  bx = GIMarshallingTests::BoxedStruct.new
42
43
  bx.long_ = 42
43
44
 
44
45
  res = GIMarshallingTests::BoxedStruct.inout bx
46
+
45
47
  assert_equal 42, bx.long_
46
48
  assert_equal 0, res.long_
47
49
  end
48
50
 
49
51
  it "has a working function #out" do
52
+ skip unless get_method_introspection_data 'GIMarshallingTests', 'BoxedStruct', 'out'
50
53
  res = GIMarshallingTests::BoxedStruct.out
51
54
  assert_equal 42, res.long_
52
55
  end
53
56
 
54
57
  it "has a working function #returnv" do
58
+ skip unless get_method_introspection_data 'GIMarshallingTests', 'BoxedStruct', 'returnv'
55
59
  res = GIMarshallingTests::BoxedStruct.returnv
56
60
  assert_equal 42, res.long_
57
61
  assert_equal ["0", "1", "2"], res.g_strv.to_a
@@ -136,7 +140,7 @@ describe "GIMarshallingTests" do
136
140
  it "creates instances with #new" do
137
141
  ob = GIMarshallingTests::Object.new 42
138
142
  assert_instance_of GIMarshallingTests::Object, ob
139
- assert_equal 42, ob.int_
143
+ assert_equal 42, ob.int
140
144
  end
141
145
 
142
146
  it "has a working function #full_inout" do
@@ -196,7 +200,7 @@ describe "GIMarshallingTests" do
196
200
 
197
201
  it "has a working virtual method #method_with_default_implementation" do
198
202
  @obj.method_with_default_implementation 104
199
- assert_equal 104, @obj.int_
203
+ assert_equal 104, @obj.int
200
204
  end
201
205
 
202
206
  # This function is only found in the header
@@ -236,7 +240,7 @@ describe "GIMarshallingTests" do
236
240
  pass
237
241
  end
238
242
 
239
- it "has a property 'int'" do
243
+ it "has a property 'int' containing the argument to #new" do
240
244
  assert_equal 42, @obj.get_property("int")
241
245
  @obj.set_property("int", 13)
242
246
  assert_equal 13, @obj.get_property("int")
@@ -248,14 +252,10 @@ describe "GIMarshallingTests" do
248
252
  pass
249
253
  end
250
254
 
251
- it "has a read-only field parent_instance containing the parent struct" do
252
- assert_instance_of GObject::Object, @obj.parent_instance
253
- assert_raises(NoMethodError) { @obj.parent_instance = nil }
254
- end
255
-
256
- it "has a read-only field int_ containing the argument to #new" do
257
- assert_equal 42, @obj.int_
258
- assert_raises(NoMethodError) { @obj.int_ = 1 }
255
+ it "has property accessors for the int property" do
256
+ assert_equal 42, @obj.int
257
+ @obj.int = 1
258
+ assert_equal 1, @obj.int
259
259
  end
260
260
  end
261
261
  end
@@ -276,13 +276,10 @@ describe "GIMarshallingTests" do
276
276
  @obj = GIMarshallingTests::OverridesObject.new
277
277
  end
278
278
 
279
- it "has a read-only field parent_instance containing the parent struct" do
280
- assert_instance_of GObject::Object, @obj.parent_instance
279
+ it "does not have field accessor methods" do
280
+ assert_raises(NoMethodError) { @obj.parent_instance }
281
281
  assert_raises(NoMethodError) { @obj.parent_instance = nil }
282
- end
283
-
284
- it "has a read-only field long_" do
285
- assert_equal 0.0, @obj.long_
282
+ assert_raises(NoMethodError) { @obj.long_ }
286
283
  assert_raises(NoMethodError) { @obj.long_ = 1 }
287
284
  end
288
285
  end
@@ -371,8 +368,8 @@ describe "GIMarshallingTests" do
371
368
  pass
372
369
  end
373
370
 
374
- it "has a read-only field parent_instance containing the parent struct" do
375
- assert_instance_of GIMarshallingTests::Object, @so.parent_instance
371
+ it "does not have field accessors" do
372
+ assert_raises(NoMethodError) { @so.parent_instance }
376
373
  assert_raises(NoMethodError) { @so.parent_instance = nil }
377
374
  end
378
375
 
@@ -381,14 +378,14 @@ describe "GIMarshallingTests" do
381
378
 
382
379
  it "has a working inherited virtual method #method_with_default_implementation" do
383
380
  @so.method_with_default_implementation 104
384
- assert_equal 104, @so.parent_instance.int_
381
+ assert_equal 104, @so.int
385
382
  end
386
383
 
387
384
  it "has a working inherited method #int8_in"
388
385
  it "has a working inherited method #int8_out"
389
386
 
390
387
  it "has a working inherited method #method" do
391
- @so.parent_instance.set_property("int", 42)
388
+ @so.set_property("int", 42)
392
389
  @so.method
393
390
  pass
394
391
  end
@@ -414,13 +411,13 @@ describe "GIMarshallingTests" do
414
411
  end
415
412
 
416
413
  it "has a working inherited method #none_in" do
417
- @so.parent_instance.set_property("int", 42)
414
+ @so.set_property("int", 42)
418
415
  @so.none_in
419
416
  pass
420
417
  end
421
418
 
422
419
  it "has a working inherited method #overridden_method" do
423
- @so.parent_instance.set_property("int", 0)
420
+ @so.set_property("int", 0)
424
421
  @so.overridden_method
425
422
  pass
426
423
  end
@@ -34,6 +34,11 @@ describe "The generated Gio module" do
34
34
 
35
35
  @it.setup_and_call :get_qdata, 1
36
36
  end
37
+
38
+ it "knows its GType" do
39
+ instance_gtype = GObject.type_from_instance @it
40
+ @it.class.get_gtype.must_equal instance_gtype
41
+ end
37
42
  end
38
43
 
39
44
  context "the FileInfo class" do
@@ -7,8 +7,8 @@ describe "The generated GObject module" do
7
7
 
8
8
  describe "#type_interfaces" do
9
9
  it "works, showing that returning an array of GType works" do
10
- tp = GObject.type_from_name 'GTypeModule'
11
- ifcs = GObject.type_interfaces tp
10
+ klass = GObject::TypeModule
11
+ ifcs = GObject.type_interfaces klass.get_gtype
12
12
  assert_equal 1, ifcs.size
13
13
  end
14
14
  end
@@ -1,7 +1,7 @@
1
1
  require File.expand_path('../gir_ffi_test_helper.rb', File.dirname(__FILE__))
2
2
 
3
3
  # Since the tests will call Gtk+ functions, Gtk+ must be initialized.
4
- require 'ffi-gtk2'
4
+ require 'ffi-gtk3'
5
5
  Gtk.init
6
6
 
7
7
  # Tests generated methods and functions in the Gtk namespace.
@@ -0,0 +1,20 @@
1
+ # coding: utf-8
2
+ require File.expand_path('../gir_ffi_test_helper.rb', File.dirname(__FILE__))
3
+
4
+ require 'gir_ffi'
5
+
6
+ GirFFI.setup :Gdk
7
+ GirFFI.setup :Pango
8
+ Gdk.init []
9
+
10
+ # Tests generated methods and functions in the Pango namespace.
11
+ describe "Building classes in the Pango namespace" do
12
+ describe "the relevant Pango::FontMap subclass" do
13
+ it "is a descendant from Pango::FontMap" do
14
+ ctx = Gdk.pango_context_get
15
+ result = ctx.get_font_map
16
+ result.class.ancestors.must_include Pango::FontMap
17
+ end
18
+ end
19
+ end
20
+