gir_ffi 0.6.6 → 0.6.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. data/History.txt +14 -0
  2. data/TODO.rdoc +23 -5
  3. data/lib/ffi-glib/array.rb +14 -15
  4. data/lib/ffi-glib/container_class_methods.rb +0 -1
  5. data/lib/ffi-glib/hash_table.rb +3 -4
  6. data/lib/ffi-glib/ptr_array.rb +12 -4
  7. data/lib/ffi-glib/sized_array.rb +27 -7
  8. data/lib/ffi-gobject.rb +14 -15
  9. data/lib/ffi-gobject/closure.rb +1 -1
  10. data/lib/ffi-gobject/object.rb +40 -15
  11. data/lib/ffi-gobject/ruby_closure.rb +0 -1
  12. data/lib/ffi-gobject/value.rb +45 -21
  13. data/lib/ffi-gobject_introspection/i_arg_info.rb +4 -0
  14. data/lib/ffi-gobject_introspection/i_base_info.rb +42 -2
  15. data/lib/ffi-gobject_introspection/i_callable_info.rb +8 -0
  16. data/lib/ffi-gobject_introspection/i_enum_info.rb +1 -4
  17. data/lib/ffi-gobject_introspection/i_interface_info.rb +1 -0
  18. data/lib/ffi-gobject_introspection/i_object_info.rb +2 -0
  19. data/lib/ffi-gobject_introspection/i_repository.rb +2 -3
  20. data/lib/ffi-gobject_introspection/i_struct_info.rb +3 -8
  21. data/lib/ffi-gobject_introspection/lib.rb +3 -0
  22. data/lib/gir_ffi-base.rb +3 -1
  23. data/lib/gir_ffi-base/gir_ffi/struct.rb +27 -0
  24. data/lib/gir_ffi-base/glib/boolean.rb +13 -1
  25. data/lib/gir_ffi-base/gobject.rb +7 -0
  26. data/lib/gir_ffi-base/gobject/lib.rb +0 -2
  27. data/lib/gir_ffi.rb +1 -3
  28. data/lib/gir_ffi/arg_helper.rb +4 -85
  29. data/lib/gir_ffi/builder.rb +5 -5
  30. data/lib/gir_ffi/builder_helper.rb +7 -0
  31. data/lib/gir_ffi/builders/argument_builder.rb +132 -0
  32. data/lib/gir_ffi/{base_argument_builder.rb → builders/base_argument_builder.rb} +32 -41
  33. data/lib/gir_ffi/builders/base_type_builder.rb +47 -0
  34. data/lib/gir_ffi/builders/callback_builder.rb +38 -0
  35. data/lib/gir_ffi/builders/constant_builder.rb +18 -0
  36. data/lib/gir_ffi/builders/enum_builder.rb +62 -0
  37. data/lib/gir_ffi/builders/error_argument_builder.rb +18 -0
  38. data/lib/gir_ffi/builders/field_builder.rb +94 -0
  39. data/lib/gir_ffi/builders/function_builder.rb +123 -0
  40. data/lib/gir_ffi/builders/interface_builder.rb +29 -0
  41. data/lib/gir_ffi/builders/mapping_method_builder.rb +88 -0
  42. data/lib/gir_ffi/builders/module_builder.rb +124 -0
  43. data/lib/gir_ffi/{null_argument_builder.rb → builders/null_argument_builder.rb} +0 -0
  44. data/lib/gir_ffi/builders/null_builder.rb +11 -0
  45. data/lib/gir_ffi/builders/object_builder.rb +123 -0
  46. data/lib/gir_ffi/{builder/property.rb → builders/property_builder.rb} +0 -0
  47. data/lib/gir_ffi/builders/registered_type_builder.rb +50 -0
  48. data/lib/gir_ffi/builders/return_value_builder.rb +68 -0
  49. data/lib/gir_ffi/builders/signal_builder.rb +91 -0
  50. data/lib/gir_ffi/builders/struct_builder.rb +35 -0
  51. data/lib/gir_ffi/builders/type_builder.rb +40 -0
  52. data/lib/gir_ffi/builders/unintrospectable_builder.rb +35 -0
  53. data/lib/gir_ffi/builders/union_builder.rb +34 -0
  54. data/lib/gir_ffi/builders/user_defined_builder.rb +103 -0
  55. data/lib/gir_ffi/builders/with_layout.rb +55 -0
  56. data/lib/gir_ffi/builders/with_methods.rb +44 -0
  57. data/lib/gir_ffi/callback_base.rb +31 -0
  58. data/lib/gir_ffi/class_base.rb +16 -10
  59. data/lib/gir_ffi/enum_base.rb +8 -4
  60. data/lib/gir_ffi/ffi_ext/pointer.rb +19 -2
  61. data/lib/gir_ffi/in_out_pointer.rb +38 -39
  62. data/lib/gir_ffi/in_pointer.rb +33 -18
  63. data/lib/gir_ffi/info_ext.rb +0 -4
  64. data/lib/gir_ffi/info_ext/i_arg_info.rb +0 -18
  65. data/lib/gir_ffi/info_ext/i_callable_info.rb +2 -1
  66. data/lib/gir_ffi/info_ext/i_registered_type_info.rb +6 -8
  67. data/lib/gir_ffi/info_ext/i_signal_info.rb +6 -21
  68. data/lib/gir_ffi/info_ext/i_type_info.rb +54 -29
  69. data/lib/gir_ffi/info_ext/safe_constant_name.rb +8 -1
  70. data/lib/gir_ffi/interface_base.rb +1 -1
  71. data/lib/gir_ffi/module_base.rb +5 -1
  72. data/lib/gir_ffi/object_base.rb +5 -1
  73. data/lib/gir_ffi/setter_argument_info.rb +4 -0
  74. data/lib/gir_ffi/signal_base.rb +21 -0
  75. data/lib/gir_ffi/struct_base.rb +24 -0
  76. data/lib/gir_ffi/type_base.rb +11 -0
  77. data/lib/gir_ffi/type_map.rb +4 -2
  78. data/lib/gir_ffi/union_base.rb +24 -0
  79. data/lib/gir_ffi/version.rb +1 -1
  80. data/tasks/test.rake +73 -7
  81. data/test/base_test_helper.rb +3 -19
  82. data/test/ffi-glib/array_test.rb +6 -0
  83. data/test/ffi-glib/ptr_array_test.rb +13 -0
  84. data/test/ffi-glib/ruby_closure_test.rb +7 -7
  85. data/test/ffi-glib/sized_array_test.rb +2 -2
  86. data/test/ffi-gobject/gobject_test.rb +3 -12
  87. data/test/ffi-gobject/object_test.rb +33 -2
  88. data/test/ffi-gobject/value_test.rb +114 -1
  89. data/test/ffi-gobject_introspection/i_enum_info_test.rb +2 -2
  90. data/test/ffi-gobject_introspection/i_object_info_test.rb +3 -3
  91. data/test/ffi-gobject_introspection/i_repository_test.rb +26 -21
  92. data/test/ffi-gobject_test.rb +14 -14
  93. data/test/gir_ffi-base/glib/boolean_test.rb +6 -0
  94. data/test/gir_ffi/arg_helper_test.rb +2 -122
  95. data/test/gir_ffi/builder_test.rb +67 -204
  96. data/test/gir_ffi/{argument_builder_test.rb → builders/argument_builder_test.rb} +230 -108
  97. data/test/gir_ffi/builders/base_argument_builder_test.rb +5 -0
  98. data/test/gir_ffi/builders/callback_builder_test.rb +50 -0
  99. data/test/gir_ffi/builders/constant_builder_test.rb +4 -0
  100. data/test/gir_ffi/{builder/type/enum_test.rb → builders/enum_builder_test.rb} +2 -3
  101. data/test/gir_ffi/builders/field_builder_test.rb +94 -0
  102. data/test/gir_ffi/{function_builder_test.rb → builders/function_builder_test.rb} +43 -24
  103. data/test/gir_ffi/{builder/type/interface_test.rb → builders/interface_builder_test.rb} +2 -2
  104. data/test/gir_ffi/{builder/module_test.rb → builders/module_builder_test.rb} +12 -13
  105. data/test/gir_ffi/{builder/type/object_test.rb → builders/object_builder_test.rb} +9 -9
  106. data/test/gir_ffi/{return_value_builder_test.rb → builders/return_value_builder_test.rb} +94 -58
  107. data/test/gir_ffi/builders/signal_builder_test.rb +62 -0
  108. data/test/gir_ffi/{builder/type/struct_test.rb → builders/struct_builder_test.rb} +36 -19
  109. data/test/gir_ffi/{builder/type/unintrospectable_test.rb → builders/unintrospectable_builder_test.rb} +3 -3
  110. data/test/gir_ffi/builders/union_builder_test.rb +29 -0
  111. data/test/gir_ffi/{builder/type/user_defined_test.rb → builders/user_defined_builder_test.rb} +2 -2
  112. data/test/gir_ffi/callback_base_test.rb +11 -0
  113. data/test/gir_ffi/class_base_test.rb +22 -22
  114. data/test/gir_ffi/ffi_ext/pointer_test.rb +18 -0
  115. data/test/gir_ffi/in_out_pointer_test.rb +0 -7
  116. data/test/gir_ffi/in_pointer_test.rb +27 -3
  117. data/test/gir_ffi/info_ext/i_signal_info_test.rb +16 -44
  118. data/test/gir_ffi/info_ext/i_type_info_test.rb +315 -74
  119. data/test/gir_ffi/info_ext/safe_constant_name_test.rb +6 -0
  120. data/test/gir_ffi/interface_base_test.rb +3 -5
  121. data/test/gir_ffi/object_base_test.rb +10 -6
  122. data/test/gir_ffi/type_map_test.rb +2 -2
  123. data/test/gir_ffi/unintrospectable_type_info_test.rb +2 -2
  124. data/test/gir_ffi_test_helper.rb +12 -4
  125. data/test/integration/generated_gimarshallingtests_test.rb +436 -76
  126. data/test/integration/generated_gio_test.rb +5 -11
  127. data/test/integration/generated_gobject_test.rb +8 -0
  128. data/test/integration/generated_regress_test.rb +755 -309
  129. data/test/integration/generated_secret_test.rb +2 -1
  130. metadata +73 -72
  131. data/lib/ffi-gobject/ruby_style.rb +0 -23
  132. data/lib/gir_ffi/argument_builder.rb +0 -154
  133. data/lib/gir_ffi/builder/field.rb +0 -60
  134. data/lib/gir_ffi/builder/module.rb +0 -127
  135. data/lib/gir_ffi/builder/type.rb +0 -39
  136. data/lib/gir_ffi/builder/type/base.rb +0 -48
  137. data/lib/gir_ffi/builder/type/callback.rb +0 -30
  138. data/lib/gir_ffi/builder/type/constant.rb +0 -22
  139. data/lib/gir_ffi/builder/type/enum.rb +0 -66
  140. data/lib/gir_ffi/builder/type/interface.rb +0 -33
  141. data/lib/gir_ffi/builder/type/object.rb +0 -134
  142. data/lib/gir_ffi/builder/type/registered_type.rb +0 -62
  143. data/lib/gir_ffi/builder/type/struct.rb +0 -34
  144. data/lib/gir_ffi/builder/type/unintrospectable.rb +0 -39
  145. data/lib/gir_ffi/builder/type/union.rb +0 -34
  146. data/lib/gir_ffi/builder/type/user_defined.rb +0 -107
  147. data/lib/gir_ffi/builder/type/with_layout.rb +0 -62
  148. data/lib/gir_ffi/builder/type/with_methods.rb +0 -64
  149. data/lib/gir_ffi/callback.rb +0 -72
  150. data/lib/gir_ffi/callback_helper.rb +0 -11
  151. data/lib/gir_ffi/error_argument_builder.rb +0 -17
  152. data/lib/gir_ffi/function_builder.rb +0 -112
  153. data/lib/gir_ffi/info_ext/i_enum_info.rb +0 -11
  154. data/lib/gir_ffi/info_ext/i_object_info.rb +0 -11
  155. data/lib/gir_ffi/info_ext/i_struct_info.rb +0 -11
  156. data/lib/gir_ffi/info_ext/i_union_info.rb +0 -12
  157. data/lib/gir_ffi/return_value_builder.rb +0 -81
  158. data/test/ffi-gobject/ruby_style_test.rb +0 -38
  159. data/test/gir_ffi/base_argument_builder_test.rb +0 -13
  160. data/test/gir_ffi/builder/type/callback_test.rb +0 -6
  161. data/test/gir_ffi/builder/type/constant_test.rb +0 -4
  162. data/test/gir_ffi/builder/type/union_test.rb +0 -12
  163. data/test/gir_ffi/callback_helper_test.rb +0 -10
  164. data/test/gir_ffi/callback_test.rb +0 -49
  165. data/test/gir_ffi/info_ext/i_arg_info_test.rb +0 -39
  166. data/test/gir_ffi/info_ext/i_object_info_test.rb +0 -14
@@ -12,5 +12,11 @@ describe GirFFI::InfoExt::SafeConstantName do
12
12
 
13
13
  assert_equal "Private___foo", info.safe_name
14
14
  end
15
+
16
+ it "makes names with dashes safe" do
17
+ mock(info).name { "this-could-be-a-signal-name" }
18
+
19
+ info.safe_name.must_equal "This_could_be_a_signal_name"
20
+ end
15
21
  end
16
22
  end
@@ -2,12 +2,10 @@ require 'gir_ffi_test_helper'
2
2
 
3
3
  describe GirFFI::InterfaceBase do
4
4
  describe "#wrap" do
5
- it "dynamically looks op the wrapped object's class" do
5
+ it "delegates conversion to the wrapped pointer" do
6
6
  mod = Module.new { extend GirFFI::InterfaceBase }
7
-
8
- mock(GirFFI::ArgHelper).object_pointer_to_object("some-pointer") { "good-result" }
9
-
10
- mod.wrap("some-pointer").must_equal "good-result"
7
+ mock(ptr = Object.new).to_object { "good-result" }
8
+ mod.wrap(ptr).must_equal "good-result"
11
9
  end
12
10
  end
13
11
  end
@@ -1,13 +1,17 @@
1
1
  require 'gir_ffi_test_helper'
2
2
 
3
3
  describe GirFFI::ObjectBase do
4
- describe "#wrap" do
5
- it "dynamically looks op the wrapped object's class" do
6
- mod = Class.new GirFFI::ObjectBase
7
-
8
- mock(GirFFI::ArgHelper).object_pointer_to_object("some-pointer") { "good-result" }
4
+ let(:derived_class) { Class.new GirFFI::ObjectBase }
5
+ describe ".wrap" do
6
+ it "delegates conversion to the wrapped pointer" do
7
+ mock(ptr = Object.new).to_object { "good-result" }
8
+ derived_class.wrap(ptr).must_equal "good-result"
9
+ end
10
+ end
9
11
 
10
- mod.wrap("some-pointer").must_equal "good-result"
12
+ describe ".to_ffitype" do
13
+ it "returns :pointer" do
14
+ derived_class.to_ffitype.must_equal :pointer
11
15
  end
12
16
  end
13
17
  end
@@ -7,9 +7,9 @@ describe GirFFI::TypeMap do
7
7
  must_equal GLib::DateMonth::Enum
8
8
  end
9
9
 
10
- it "returns the nested FFI::Struct for an Struct module" do
10
+ it "returns the class itself for a Struct class" do
11
11
  GirFFI::TypeMap.type_specification_to_ffitype(GObject::EnumValue).
12
- must_equal GObject::EnumValue::Struct
12
+ must_equal GObject::EnumValue
13
13
  end
14
14
  end
15
15
  end
@@ -10,7 +10,7 @@ describe GirFFI::UnintrospectableTypeInfo do
10
10
  end
11
11
 
12
12
  describe "#parent" do
13
- context "when the GIR knows about the parent gtype" do
13
+ describe "when the GIR knows about the parent gtype" do
14
14
  it "finds the parent's info by gtype" do
15
15
  gobject = Object.new
16
16
  gir = Object.new
@@ -24,7 +24,7 @@ describe GirFFI::UnintrospectableTypeInfo do
24
24
  end
25
25
  end
26
26
 
27
- context "when the GIR does not know about the parent gtype" do
27
+ describe "when the GIR does not know about the parent gtype" do
28
28
  it "creates a new UnintrospectableTypeInfo from the parent gtype" do
29
29
  gobject = Object.new
30
30
  gir = Object.new
@@ -2,10 +2,6 @@ require 'introspection_test_helper'
2
2
 
3
3
  require 'gir_ffi'
4
4
 
5
- # Need a dummy module for some tests.
6
- module DummyLib
7
- end
8
-
9
5
  # Global sequence provider. Needed to make unique class names.
10
6
  class Sequence
11
7
  @@seq = 0
@@ -19,10 +15,22 @@ class Minitest::Test
19
15
  code.gsub(/(^\s*|\s*$)/, "")
20
16
  end
21
17
 
18
+ def get_field_introspection_data namespace, klass, name
19
+ get_introspection_data(namespace, klass).find_field name
20
+ end
21
+
22
22
  def get_method_introspection_data namespace, klass, name
23
23
  get_introspection_data(namespace, klass).find_method name
24
24
  end
25
25
 
26
+ def get_property_introspection_data namespace, klass, name
27
+ get_introspection_data(namespace, klass).find_property name
28
+ end
29
+
30
+ def get_signal_introspection_data namespace, klass, name
31
+ get_introspection_data(namespace, klass).find_signal name
32
+ end
33
+
26
34
  SAVED_MODULES = {}
27
35
 
28
36
  def save_module name
@@ -8,38 +8,38 @@ GirFFI.setup :GIMarshallingTests
8
8
  # Tests generated methods and functions in the GIMarshallingTests namespace.
9
9
  describe GIMarshallingTests do
10
10
  describe "GIMarshallingTests::BoxedStruct" do
11
+ let(:instance) { GIMarshallingTests::BoxedStruct.new }
12
+
13
+ it "has a writable field long_" do
14
+ instance.long_ = 42
15
+ assert_equal 42, instance.long_
16
+ instance.long_ = 43
17
+ assert_equal 43, instance.long_
18
+ end
19
+
20
+ it "has a writable field string_" do
21
+ skip unless get_field_introspection_data("GIMarshallingTests", "BoxedStruct", "string_")
22
+ instance.string_ = "foobar"
23
+ instance.string_.must_equal "foobar"
24
+ end
25
+
26
+ it "has a writable field g_strv" do
27
+ instance.g_strv.must_be :==, []
28
+ instance.g_strv = ["foo", "bar"]
29
+ instance.g_strv.must_be :==, ["foo", "bar"]
30
+ end
31
+
11
32
  it "creates an instance using #new" do
12
33
  bx = GIMarshallingTests::BoxedStruct.new
13
34
  assert_instance_of GIMarshallingTests::BoxedStruct, bx
14
35
  end
15
36
 
16
- let(:instance) { GIMarshallingTests::BoxedStruct.new }
17
-
18
37
  it "has a working method #inv" do
19
38
  instance.long_ = 42
20
39
  instance.inv
21
40
  pass
22
41
  end
23
42
 
24
- describe "an instance" do
25
- before do
26
- @bx = instance
27
- @bx.long_ = 42
28
- end
29
-
30
- it "has a writable field long_" do
31
- assert_equal 42, @bx.long_
32
- @bx.long_ = 43
33
- assert_equal 43, @bx.long_
34
- end
35
-
36
- it "has a writable field g_strv" do
37
- @bx.g_strv.must_be :==, []
38
- @bx.g_strv = ["foo", "bar"]
39
- @bx.g_strv.must_be :==, ["foo", "bar"]
40
- end
41
- end
42
-
43
43
  it "has a working function #inout" do
44
44
  bx = GIMarshallingTests::BoxedStruct.new
45
45
  bx.long_ = 42
@@ -200,10 +200,14 @@ describe GIMarshallingTests do
200
200
  end
201
201
 
202
202
  describe "GIMarshallingTests::NestedStruct" do
203
- it "contains a SimpleStruct" do
204
- ns = GIMarshallingTests::NestedStruct.new
203
+ let(:instance) { GIMarshallingTests::NestedStruct.new }
204
+ it "has a writable field simple_struct" do
205
205
  assert_instance_of GIMarshallingTests::SimpleStruct,
206
- ns.simple_struct
206
+ instance.simple_struct
207
+ new_struct = GIMarshallingTests::SimpleStruct.new
208
+ new_struct.int8 = 42
209
+ instance.simple_struct = new_struct
210
+ instance.simple_struct.int8.must_equal 42
207
211
  end
208
212
  end
209
213
 
@@ -214,7 +218,7 @@ describe GIMarshallingTests do
214
218
  it "has the member :value2" do
215
219
  assert_equal 2, GIMarshallingTests::NoTypeFlags[:value2]
216
220
  end
217
- it "has the member :value3" do
221
+ it "has the member :value" do
218
222
  assert_equal 4, GIMarshallingTests::NoTypeFlags[:value3]
219
223
  end
220
224
  it "has the member :mask" do
@@ -226,7 +230,14 @@ describe GIMarshallingTests do
226
230
  end
227
231
 
228
232
  describe "GIMarshallingTests::NotSimpleStruct" do
229
- it "must be tested"
233
+ let(:instance) { GIMarshallingTests::NotSimpleStruct.new }
234
+
235
+ it "has a writable field pointer" do
236
+ instance.pointer.must_be_nil
237
+ nested = GIMarshallingTests::NestedStruct.new
238
+ instance.pointer = nested
239
+ instance.pointer.must_equal nested
240
+ end
230
241
  end
231
242
 
232
243
  it "has the constant OVERRIDES_CONSTANT" do
@@ -322,7 +333,6 @@ describe GIMarshallingTests do
322
333
  skip "Needs vfunc setup"
323
334
  end
324
335
 
325
- # TODO: Avoid using common method names?
326
336
  it "has a working method #method" do
327
337
  instance.method
328
338
  pass
@@ -423,16 +433,21 @@ describe GIMarshallingTests do
423
433
  skip "Needs vfunc setup"
424
434
  end
425
435
 
426
- it "has a property 'int' containing the argument to #new" do
427
- assert_equal 42, instance.get_property("int")
428
- instance.set_property("int", 13)
429
- assert_equal 13, instance.get_property("int")
430
- end
431
-
432
- it "has property accessors for the int property" do
433
- assert_equal 42, instance.int
434
- instance.int = 1
435
- assert_equal 1, instance.int
436
+ describe "its 'int' property" do
437
+ it "can be retrieved with #get_property" do
438
+ assert_equal 42, instance.get_property("int")
439
+ end
440
+ it "can be retrieved with #int" do
441
+ assert_equal 42, instance.int
442
+ end
443
+ it "can be set with #set_property" do
444
+ instance.set_property("int", 13)
445
+ assert_equal 13, instance.get_property("int")
446
+ end
447
+ it "can be set with #int=" do
448
+ instance.int = 1
449
+ assert_equal 1, instance.int
450
+ end
436
451
  end
437
452
  end
438
453
 
@@ -465,6 +480,11 @@ describe GIMarshallingTests do
465
480
  describe "GIMarshallingTests::OverridesStruct" do
466
481
  let(:instance) { GIMarshallingTests::OverridesStruct.new }
467
482
 
483
+ it "has a writable field long_" do
484
+ instance.long_ = 43
485
+ instance.long_.must_equal 43
486
+ end
487
+
468
488
  it "creates an instance using #new" do
469
489
  ob = GIMarshallingTests::OverridesStruct.new
470
490
  assert_instance_of GIMarshallingTests::OverridesStruct, ob
@@ -478,11 +498,6 @@ describe GIMarshallingTests do
478
498
  ob = GIMarshallingTests::OverridesStruct.returnv
479
499
  assert_instance_of GIMarshallingTests::OverridesStruct, ob
480
500
  end
481
-
482
- it "has a writable field long_" do
483
- instance.long_ = 43
484
- instance.long_.must_equal 43
485
- end
486
501
  end
487
502
 
488
503
  describe "GIMarshallingTests::PointerStruct" do
@@ -493,18 +508,18 @@ describe GIMarshallingTests do
493
508
 
494
509
  let(:instance) { GIMarshallingTests::PointerStruct.new }
495
510
 
496
- it "has a working method #inv" do
497
- instance.long_ = 42
498
- instance.inv
499
- pass
500
- end
501
-
502
511
  it "has a writable field long_" do
503
512
  assert_equal 0, instance.long_
504
513
  instance.long_ = 1056
505
514
  assert_equal 1056, instance.long_
506
515
  end
507
516
 
517
+ it "has a working method #inv" do
518
+ instance.long_ = 42
519
+ instance.inv
520
+ pass
521
+ end
522
+
508
523
  it "has a working function #returnv" do
509
524
  ob = GIMarshallingTests::PointerStruct.returnv
510
525
  assert_instance_of GIMarshallingTests::PointerStruct, ob
@@ -517,19 +532,365 @@ describe GIMarshallingTests do
517
532
  assert_instance_of GIMarshallingTests::PropertiesObject, ob
518
533
  end
519
534
 
520
- it "has the property 'some-boolean'"
521
- it "has the property 'some-boxed-struct'"
522
- it "has the property 'some-char'"
523
- it "has the property 'some-double'"
524
- it "has the property 'some-float'"
525
- it "has the property 'some-int'"
526
- it "has the property 'some-int64'"
527
- it "has the property 'some-long'"
528
- it "has the property 'some-strv'"
529
- it "has the property 'some-uchar'"
530
- it "has the property 'some-uint'"
531
- it "has the property 'some-uint64'"
532
- it "has the property 'some-ulong'"
535
+ let(:instance) { GIMarshallingTests::PropertiesObject.new }
536
+
537
+ describe "its 'some-boolean' property" do
538
+ it "can be retrieved with #get_property" do
539
+ instance.get_property("some-boolean").must_equal false
540
+ end
541
+
542
+ it "can be retrieved with #some_boolean" do
543
+ instance.some_boolean.must_equal false
544
+ end
545
+
546
+ it "can be set with #set_property" do
547
+ instance.set_property("some-boolean", true)
548
+ instance.get_property("some-boolean").must_equal true
549
+ end
550
+
551
+ it "can be set with #some_boolean=" do
552
+ instance.some_boolean = true
553
+ instance.get_property("some-boolean").must_equal true
554
+ end
555
+ end
556
+
557
+ describe "its 'some-boxed-glist' property" do
558
+ before do
559
+ skip unless get_property_introspection_data('GIMarshallingTests',
560
+ 'PropertiesObject',
561
+ 'some-boxed-glist')
562
+ end
563
+
564
+ it "can be retrieved with #get_property" do
565
+ instance.get_property("some-boxed-glist").must_equal nil
566
+ end
567
+
568
+ it "can be retrieved with #some_boxed_glist" do
569
+ instance.some_boxed_glist.must_equal nil
570
+ end
571
+
572
+ it "can be set with #set_property" do
573
+ instance.set_property("some-boxed-glist", [1, 2, 3])
574
+ instance.get_property("some-boxed-glist").to_a.must_equal [1, 2, 3]
575
+ end
576
+
577
+ it "can be set with #some_boxed_glist=" do
578
+ instance.some_boxed_glist = [1, 2, 3]
579
+ instance.some_boxed_glist.to_a.must_equal [1, 2, 3]
580
+ end
581
+ end
582
+
583
+ describe "its 'some-boxed-struct' property" do
584
+ before do
585
+ skip unless get_property_introspection_data('GIMarshallingTests',
586
+ 'PropertiesObject',
587
+ 'some-boxed-struct')
588
+ end
589
+
590
+ it "can be retrieved with #get_property" do
591
+ instance.get_property("some-boxed-struct").must_equal nil
592
+ end
593
+
594
+ it "can be retrieved with #some_boxed_struct" do
595
+ instance.some_boxed_struct.must_equal nil
596
+ end
597
+
598
+ it "can be set with #set_property" do
599
+ boxed = GIMarshallingTests::BoxedStruct.new
600
+ boxed.long_ = 42
601
+ instance.set_property("some-boxed-struct", boxed)
602
+ instance.get_property("some-boxed-struct").long_.must_equal 42
603
+ end
604
+
605
+ it "can be set with #some_boxed_struct=" do
606
+ boxed = GIMarshallingTests::BoxedStruct.new
607
+ boxed.long_ = 43
608
+ instance.some_boxed_struct = boxed
609
+ instance.some_boxed_struct.long_.must_equal 43
610
+ end
611
+ end
612
+
613
+ describe "its 'some-char' property" do
614
+ it "can be retrieved with #get_property" do
615
+ instance.get_property("some-char").must_equal 0
616
+ end
617
+
618
+ it "can be retrieved with #some_char" do
619
+ instance.some_char.must_equal 0
620
+ end
621
+
622
+ it "can be set with #set_property" do
623
+ instance.set_property "some-char", 42
624
+ instance.get_property("some-char").must_equal 42
625
+ end
626
+
627
+ it "can be set with #some_char=" do
628
+ instance.some_char = 43
629
+ instance.some_char.must_equal 43
630
+ end
631
+ end
632
+
633
+ describe "its 'some-double' property" do
634
+ it "can be retrieved with #get_property" do
635
+ instance.get_property("some-double").must_equal 0.0
636
+ end
637
+
638
+ it "can be retrieved with #some_double" do
639
+ instance.some_double.must_equal 0.0
640
+ end
641
+
642
+ it "can be set with #set_property" do
643
+ instance.set_property("some-double", 3.14)
644
+ instance.get_property("some-double").must_equal 3.14
645
+ end
646
+
647
+ it "can be set with #some_double=" do
648
+ instance.some_double = 3.14
649
+ instance.some_double.must_equal 3.14
650
+ end
651
+ end
652
+
653
+ describe "its 'some-float' property" do
654
+ it "can be retrieved with #get_property" do
655
+ instance.get_property("some-float").must_equal 0.0
656
+ end
657
+
658
+ it "can be retrieved with #some_float" do
659
+ instance.some_float.must_equal 0.0
660
+ end
661
+
662
+ it "can be set with #set_property" do
663
+ instance.set_property("some-float", 3.14)
664
+ instance.get_property("some-float").must_be_close_to 3.14
665
+ end
666
+
667
+ it "can be set with #some_float=" do
668
+ instance.some_float = 3.14
669
+ instance.some_float.must_be_close_to 3.14
670
+ end
671
+ end
672
+
673
+ describe "its 'some-int' property" do
674
+ it "can be retrieved with #get_property" do
675
+ instance.get_property("some-int").must_equal 0
676
+ end
677
+
678
+ it "can be retrieved with #some_int" do
679
+ instance.some_int.must_equal 0
680
+ end
681
+
682
+ it "can be set with #set_property" do
683
+ instance.set_property "some-int", 4242
684
+ instance.get_property("some-int").must_equal 4242
685
+ end
686
+
687
+ it "can be set with #some_int=" do
688
+ instance.some_int = 4243
689
+ instance.some_int.must_equal 4243
690
+ end
691
+ end
692
+
693
+ describe "its 'some-int64' property" do
694
+ it "can be retrieved with #get_property" do
695
+ instance.get_property("some-int64").must_equal 0
696
+ end
697
+
698
+ it "can be retrieved with #some_int64" do
699
+ instance.some_int64.must_equal 0
700
+ end
701
+
702
+ it "can be set with #set_property" do
703
+ instance.set_property "some-int64", 42_000_000_000_000
704
+ instance.get_property("some-int64").must_equal 42_000_000_000_000
705
+ end
706
+
707
+ it "can be set with #some_int64=" do
708
+ instance.some_int64 = 43_000_000_000_000
709
+ instance.some_int64.must_equal 43_000_000_000_000
710
+ end
711
+ end
712
+
713
+ describe "its 'some-long' property" do
714
+ it "can be retrieved with #get_property" do
715
+ instance.get_property("some-long").must_equal 0
716
+ end
717
+
718
+ it "can be retrieved with #some_long" do
719
+ instance.some_long.must_equal 0
720
+ end
721
+
722
+ it "can be set with #set_property" do
723
+ instance.set_property "some-long", 4242
724
+ instance.get_property("some-long").must_equal 4242
725
+ end
726
+
727
+ it "can be set with #some_long=" do
728
+ instance.some_long = 4243
729
+ instance.some_long.must_equal 4243
730
+ end
731
+ end
732
+
733
+ describe "its 'some-object' property" do
734
+ before do
735
+ skip unless get_property_introspection_data('GIMarshallingTests',
736
+ 'PropertiesObject',
737
+ 'some-object')
738
+ end
739
+
740
+ it "can be retrieved with #get_property" do
741
+ instance.get_property("some-object").must_be_nil
742
+ end
743
+
744
+ it "can be retrieved with #some_object" do
745
+ instance.some_object.must_be_nil
746
+ end
747
+
748
+ it "can be set with #set_property" do
749
+ ob = GIMarshallingTests::Object.new 42
750
+ instance.set_property "some-object", ob
751
+ instance.get_property("some-object").must_equal ob
752
+ end
753
+
754
+ it "can be set with #some_object=" do
755
+ ob = GIMarshallingTests::Object.new 42
756
+ instance.some_object = ob
757
+ instance.some_object.must_equal ob
758
+ end
759
+ end
760
+
761
+ describe "its 'some-strv' property" do
762
+ before do
763
+ skip unless get_property_introspection_data('GIMarshallingTests',
764
+ 'PropertiesObject',
765
+ 'some-strv')
766
+ end
767
+
768
+ it "can be retrieved with #get_property" do
769
+ instance.get_property("some-strv").must_be :==, []
770
+ end
771
+
772
+ it "can be retrieved with #some_strv" do
773
+ instance.some_strv.must_be :==, []
774
+ end
775
+
776
+ it "can be set with #set_property" do
777
+ instance.set_property("some-strv", ["foo", "bar"])
778
+ instance.get_property("some-strv").must_be :==, ["foo", "bar"]
779
+ end
780
+
781
+ it "can be set with #some_strv=" do
782
+ instance.some_strv = ["foo", "bar"]
783
+ instance.some_strv.must_be :==, ["foo", "bar"]
784
+ end
785
+ end
786
+
787
+ describe "its 'some-uchar' property" do
788
+ it "can be retrieved with #get_property" do
789
+ instance.get_property("some-uchar").must_equal 0
790
+ end
791
+
792
+ it "can be retrieved with #some_uchar" do
793
+ instance.some_uchar.must_equal 0
794
+ end
795
+
796
+ it "can be set with #set_property" do
797
+ instance.set_property "some-uchar", 42
798
+ instance.get_property("some-uchar").must_equal 42
799
+ end
800
+
801
+ it "can be set with #some_uchar=" do
802
+ instance.some_uchar = 43
803
+ instance.some_uchar.must_equal 43
804
+ end
805
+ end
806
+
807
+ describe "its 'some-uuint' property" do
808
+ it "can be retrieved with #get_property" do
809
+ instance.get_property("some-uint").must_equal 0
810
+ end
811
+
812
+ it "can be retrieved with #some_uint" do
813
+ instance.some_uint.must_equal 0
814
+ end
815
+
816
+ it "can be set with #set_property" do
817
+ instance.set_property "some-uint", 4242
818
+ instance.get_property("some-uint").must_equal 4242
819
+ end
820
+
821
+ it "can be set with #some_uint=" do
822
+ instance.some_uint = 4243
823
+ instance.some_uint.must_equal 4243
824
+ end
825
+ end
826
+
827
+ describe "its 'some-uint64' property" do
828
+ it "can be retrieved with #get_property" do
829
+ instance.get_property("some-uint64").must_equal 0
830
+ end
831
+
832
+ it "can be retrieved with #some_uint64" do
833
+ instance.some_uint64.must_equal 0
834
+ end
835
+
836
+ it "can be set with #set_property" do
837
+ instance.set_property "some-uint64", 42_000_000_000_000
838
+ instance.get_property("some-uint64").must_equal 42_000_000_000_000
839
+ end
840
+
841
+ it "can be set with #some_uint64=" do
842
+ instance.some_uint64 = 43_000_000_000_000
843
+ instance.some_uint64.must_equal 43_000_000_000_000
844
+ end
845
+ end
846
+
847
+ describe "its 'some-ulong' property" do
848
+ it "can be retrieved with #get_property" do
849
+ instance.get_property("some-ulong").must_equal 0
850
+ end
851
+
852
+ it "can be retrieved with #some_ulong" do
853
+ instance.some_ulong.must_equal 0
854
+ end
855
+
856
+ it "can be set with #set_property" do
857
+ instance.set_property "some-ulong", 4242
858
+ instance.get_property("some-ulong").must_equal 4242
859
+ end
860
+
861
+ it "can be set with #some_ulong=" do
862
+ instance.some_ulong = 4243
863
+ instance.some_ulong.must_equal 4243
864
+ end
865
+ end
866
+
867
+ describe "its 'some-variant' property" do
868
+ before do
869
+ skip unless get_property_introspection_data('GIMarshallingTests',
870
+ 'PropertiesObject',
871
+ 'some-variant')
872
+ end
873
+
874
+ it "can be retrieved with #get_property" do
875
+ instance.get_property("some-variant").must_be_nil
876
+ end
877
+
878
+ it "can be retrieved with #some_variant" do
879
+ instance.some_variant.must_be_nil
880
+ end
881
+
882
+ it "can be set with #set_property" do
883
+ value = GLib::Variant.new_string("Foo")
884
+ instance.set_property "some-variant", value
885
+ instance.get_property("some-variant").must_equal value
886
+ end
887
+
888
+ it "can be set with #some_variant=" do
889
+ value = GLib::Variant.new_string("Foo")
890
+ instance.some_variant = value
891
+ instance.some_variant.must_equal value
892
+ end
893
+ end
533
894
  end
534
895
 
535
896
  describe "GIMarshallingTests::SecondEnum" do
@@ -549,6 +910,18 @@ describe GIMarshallingTests do
549
910
 
550
911
  let(:instance) { GIMarshallingTests::SimpleStruct.new }
551
912
 
913
+ it "has a writable field long_" do
914
+ instance.long_.must_equal 0
915
+ instance.long_ = 1056
916
+ instance.long_.must_equal 1056
917
+ end
918
+
919
+ it "has a writable field int8" do
920
+ instance.int8.must_equal 0
921
+ instance.int8 = -43
922
+ instance.int8.must_equal(-43)
923
+ end
924
+
552
925
  it "has a working method #inv" do
553
926
  instance.long_ = 6
554
927
  instance.int8 = 7
@@ -563,18 +936,6 @@ describe GIMarshallingTests do
563
936
  pass
564
937
  end
565
938
 
566
- it "has a writable field long_" do
567
- assert_equal 0, instance.long_
568
- instance.long_ = 1056
569
- assert_equal 1056, instance.long_
570
- end
571
-
572
- it "has a writable field int8" do
573
- assert_equal 0, instance.int8
574
- instance.int8 = -43
575
- assert_equal(-43, instance.int8)
576
- end
577
-
578
939
  it "has a working function #returnv" do
579
940
  ss = GIMarshallingTests::SimpleStruct.returnv
580
941
  assert_instance_of GIMarshallingTests::SimpleStruct, ss
@@ -1523,9 +1884,8 @@ describe GIMarshallingTests do
1523
1884
  end
1524
1885
 
1525
1886
  it "has a working function #gvalue_flat_array" do
1526
- # TODO: Convert array of Ruby values to GValues automatically?
1527
- arr = [42, "42", true].map { |val| GObject::Value.wrap_ruby_value val }
1528
- GIMarshallingTests.gvalue_flat_array arr
1887
+ GIMarshallingTests.gvalue_flat_array [42, "42", true]
1888
+ pass
1529
1889
  end
1530
1890
 
1531
1891
  it "has a working function #gvalue_flat_array_round_trip" do