gir_ffi 0.7.7 → 0.7.8

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 (135) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +9 -0
  3. data/lib/ffi-glib/array.rb +1 -1
  4. data/lib/ffi-glib/error.rb +1 -2
  5. data/lib/ffi-glib/hash_table.rb +2 -2
  6. data/lib/ffi-glib/variant.rb +1 -1
  7. data/lib/ffi-gobject/base.rb +23 -23
  8. data/lib/ffi-gobject/object.rb +7 -3
  9. data/lib/ffi-gobject/value.rb +6 -1
  10. data/lib/ffi-gobject.rb +9 -6
  11. data/lib/ffi-gobject_introspection/i_base_info.rb +3 -3
  12. data/lib/ffi-gobject_introspection/i_constant_info.rb +1 -1
  13. data/lib/ffi-gobject_introspection/i_repository.rb +4 -1
  14. data/lib/ffi-gobject_introspection/i_type_info.rb +1 -1
  15. data/lib/ffi-gobject_introspection/i_unresolved_info.rb +7 -0
  16. data/lib/ffi-gobject_introspection/lib.rb +1 -1
  17. data/lib/gir_ffi/builders/argument_builder.rb +1 -1
  18. data/lib/gir_ffi/builders/c_to_ruby_convertor.rb +37 -29
  19. data/lib/gir_ffi/builders/callback_argument_builder.rb +57 -27
  20. data/lib/gir_ffi/builders/closure_convertor.rb +12 -8
  21. data/lib/gir_ffi/builders/closure_to_pointer_convertor.rb +12 -8
  22. data/lib/gir_ffi/builders/constructor_result_convertor.rb +11 -7
  23. data/lib/gir_ffi/builders/field_builder.rb +1 -1
  24. data/lib/gir_ffi/builders/function_builder.rb +1 -1
  25. data/lib/gir_ffi/builders/mapping_method_builder.rb +1 -1
  26. data/lib/gir_ffi/builders/marshalling_method_builder.rb +2 -2
  27. data/lib/gir_ffi/builders/method_template.rb +1 -1
  28. data/lib/gir_ffi/builders/null_convertor.rb +11 -7
  29. data/lib/gir_ffi/builders/property_builder.rb +1 -1
  30. data/lib/gir_ffi/builders/ruby_to_c_convertor.rb +17 -13
  31. data/lib/gir_ffi/error_argument_info.rb +1 -1
  32. data/lib/gir_ffi/ffi_ext/pointer.rb +1 -1
  33. data/lib/gir_ffi/info_ext/i_unresolved_info.rb +12 -0
  34. data/lib/gir_ffi/info_ext/safe_constant_name.rb +2 -2
  35. data/lib/gir_ffi/info_ext/safe_function_name.rb +1 -1
  36. data/lib/gir_ffi/info_ext.rb +1 -0
  37. data/lib/gir_ffi/module_base.rb +1 -1
  38. data/lib/gir_ffi/receiver_argument_info.rb +15 -12
  39. data/lib/gir_ffi/user_data_argument_info.rb +17 -15
  40. data/lib/gir_ffi/user_data_type_info.rb +14 -12
  41. data/lib/gir_ffi/version.rb +1 -1
  42. data/lib/gir_ffi-base/gobject/lib.rb +1 -1
  43. data/test/base_test_helper.rb +15 -15
  44. data/test/ffi-glib/array_test.rb +38 -38
  45. data/test/ffi-glib/byte_array_test.rb +6 -7
  46. data/test/ffi-glib/bytes_test.rb +9 -9
  47. data/test/ffi-glib/hash_table_test.rb +26 -23
  48. data/test/ffi-glib/iconv_test.rb +5 -5
  49. data/test/ffi-glib/list_test.rb +16 -16
  50. data/test/ffi-glib/main_loop_test.rb +6 -6
  51. data/test/ffi-glib/ptr_array_test.rb +45 -45
  52. data/test/ffi-glib/ruby_closure_test.rb +6 -6
  53. data/test/ffi-glib/s_list_test.rb +15 -15
  54. data/test/ffi-glib/strv_test.rb +21 -21
  55. data/test/ffi-glib/variant_test.rb +4 -4
  56. data/test/ffi-gobject/gobject_test.rb +35 -35
  57. data/test/ffi-gobject/object_class_test.rb +1 -1
  58. data/test/ffi-gobject/object_test.rb +29 -6
  59. data/test/ffi-gobject/value_test.rb +66 -52
  60. data/test/ffi-gobject_introspection/i_base_info_test.rb +10 -11
  61. data/test/ffi-gobject_introspection/i_constant_info_test.rb +6 -6
  62. data/test/ffi-gobject_introspection/i_enum_info_test.rb +4 -5
  63. data/test/ffi-gobject_introspection/i_function_info_test.rb +0 -2
  64. data/test/ffi-gobject_introspection/i_object_info_test.rb +5 -5
  65. data/test/ffi-gobject_introspection/i_registered_type_info_test.rb +9 -8
  66. data/test/ffi-gobject_introspection/i_repository_test.rb +16 -16
  67. data/test/ffi-gobject_introspection/i_type_info_test.rb +16 -2
  68. data/test/ffi-gobject_introspection/lib_test.rb +2 -2
  69. data/test/ffi-gobject_test.rb +50 -40
  70. data/test/gir_ffi/arg_helper_test.rb +5 -5
  71. data/test/gir_ffi/builder_test.rb +41 -41
  72. data/test/gir_ffi/builders/argument_builder_test.rb +240 -207
  73. data/test/gir_ffi/builders/base_argument_builder_test.rb +0 -1
  74. data/test/gir_ffi/builders/callback_argument_builder_test.rb +81 -15
  75. data/test/gir_ffi/builders/callback_builder_test.rb +39 -14
  76. data/test/gir_ffi/builders/callback_return_value_builder_test.rb +41 -33
  77. data/test/gir_ffi/builders/enum_builder_test.rb +3 -3
  78. data/test/gir_ffi/builders/field_builder_test.rb +17 -17
  79. data/test/gir_ffi/builders/function_builder_test.rb +16 -16
  80. data/test/gir_ffi/builders/interface_builder_test.rb +9 -7
  81. data/test/gir_ffi/builders/module_builder_test.rb +5 -6
  82. data/test/gir_ffi/builders/object_builder_test.rb +24 -19
  83. data/test/gir_ffi/builders/property_builder_test.rb +25 -23
  84. data/test/gir_ffi/builders/registered_type_builder_test.rb +11 -11
  85. data/test/gir_ffi/builders/return_value_builder_test.rb +237 -197
  86. data/test/gir_ffi/builders/signal_closure_builder_test.rb +29 -22
  87. data/test/gir_ffi/builders/struct_builder_test.rb +10 -10
  88. data/test/gir_ffi/builders/unintrospectable_builder_test.rb +8 -8
  89. data/test/gir_ffi/builders/union_builder_test.rb +5 -6
  90. data/test/gir_ffi/builders/user_defined_builder_test.rb +42 -33
  91. data/test/gir_ffi/builders/vfunc_builder_test.rb +37 -30
  92. data/test/gir_ffi/callback_base_test.rb +4 -5
  93. data/test/gir_ffi/class_base_test.rb +35 -28
  94. data/test/gir_ffi/error_type_info_test.rb +14 -14
  95. data/test/gir_ffi/ffi_ext/pointer_test.rb +4 -4
  96. data/test/gir_ffi/g_type_test.rb +6 -6
  97. data/test/gir_ffi/in_out_pointer_test.rb +27 -27
  98. data/test/gir_ffi/in_pointer_test.rb +54 -50
  99. data/test/gir_ffi/info_ext/i_callable_info_test.rb +8 -7
  100. data/test/gir_ffi/info_ext/i_callback_info_test.rb +7 -7
  101. data/test/gir_ffi/info_ext/i_field_info_test.rb +10 -8
  102. data/test/gir_ffi/info_ext/i_function_info_test.rb +17 -15
  103. data/test/gir_ffi/info_ext/i_signal_info_test.rb +10 -8
  104. data/test/gir_ffi/info_ext/i_type_info_test.rb +158 -155
  105. data/test/gir_ffi/info_ext/i_unresolved_info_test.rb +17 -0
  106. data/test/gir_ffi/info_ext/safe_constant_name_test.rb +12 -10
  107. data/test/gir_ffi/info_ext/safe_function_name_test.rb +12 -10
  108. data/test/gir_ffi/interface_base_test.rb +6 -6
  109. data/test/gir_ffi/method_stubber_test.rb +16 -13
  110. data/test/gir_ffi/object_base_test.rb +6 -6
  111. data/test/gir_ffi/sized_array_test.rb +23 -23
  112. data/test/gir_ffi/type_map_test.rb +3 -3
  113. data/test/gir_ffi/unintrospectable_type_info_test.rb +18 -18
  114. data/test/gir_ffi/user_defined_property_info_test.rb +4 -4
  115. data/test/gir_ffi/user_defined_type_info_test.rb +16 -16
  116. data/test/gir_ffi/variable_name_generator_test.rb +6 -6
  117. data/test/gir_ffi/version_test.rb +1 -1
  118. data/test/gir_ffi/zero_terminated_test.rb +16 -17
  119. data/test/gir_ffi-base/glib/boolean_test.rb +13 -13
  120. data/test/gir_ffi-base/glib/strv_test.rb +11 -11
  121. data/test/gir_ffi_test.rb +18 -18
  122. data/test/gir_ffi_test_helper.rb +13 -18
  123. data/test/integration/derived_classes_test.rb +8 -8
  124. data/test/integration/generated_gimarshallingtests_test.rb +794 -792
  125. data/test/integration/generated_gio_test.rb +25 -26
  126. data/test/integration/generated_glib_test.rb +8 -2
  127. data/test/integration/generated_gobject_test.rb +16 -9
  128. data/test/integration/generated_pango_ft2_test.rb +1 -2
  129. data/test/integration/generated_pango_test.rb +2 -2
  130. data/test/integration/generated_regress_test.rb +785 -705
  131. data/test/integration/generated_secret_test.rb +5 -5
  132. data/test/integration/method_lookup_test.rb +5 -5
  133. data/test/introspection_test_helper.rb +3 -1
  134. data/test/minitest/stats_plugin.rb +3 -3
  135. metadata +6 -3
@@ -3,22 +3,24 @@ require 'gir_ffi_test_helper'
3
3
  describe GirFFI::Builders::SignalClosureBuilder do
4
4
  let(:builder) { GirFFI::Builders::SignalClosureBuilder.new signal_info }
5
5
 
6
- describe "#build_class" do
6
+ describe '#build_class' do
7
7
  let(:signal_info) {
8
- get_signal_introspection_data "Regress", "TestObj", "test" }
8
+ get_signal_introspection_data 'Regress', 'TestObj', 'test'
9
+ }
9
10
 
10
- it "builds a descendant of RubyClosure" do
11
+ it 'builds a descendant of RubyClosure' do
11
12
  klass = builder.build_class
12
13
  klass.ancestors.must_include GObject::RubyClosure
13
14
  end
14
15
  end
15
16
 
16
- describe "#marshaller_definition" do
17
- describe "for a signal with no arguments or return value" do
17
+ describe '#marshaller_definition' do
18
+ describe 'for a signal with no arguments or return value' do
18
19
  let(:signal_info) {
19
- get_signal_introspection_data "Regress", "TestObj", "test" }
20
+ get_signal_introspection_data 'Regress', 'TestObj', 'test'
21
+ }
20
22
 
21
- it "returns a valid marshaller converting only the receiver" do
23
+ it 'returns a valid marshaller converting only the receiver' do
22
24
  expected = <<-CODE.reset_indentation
23
25
  def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
24
26
  _instance = param_values.first.get_value_plain
@@ -31,11 +33,12 @@ describe GirFFI::Builders::SignalClosureBuilder do
31
33
  end
32
34
  end
33
35
 
34
- describe "for a signal with an argument and a return value" do
36
+ describe 'for a signal with an argument and a return value' do
35
37
  let(:signal_info) {
36
- get_signal_introspection_data "Regress", "TestObj", "sig-with-int64-prop" }
38
+ get_signal_introspection_data 'Regress', 'TestObj', 'sig-with-int64-prop'
39
+ }
37
40
 
38
- it "returns a valid mapping method" do
41
+ it 'returns a valid mapping method' do
39
42
  skip unless signal_info
40
43
 
41
44
  expected = <<-CODE.reset_indentation
@@ -52,11 +55,12 @@ describe GirFFI::Builders::SignalClosureBuilder do
52
55
  end
53
56
  end
54
57
 
55
- describe "for a signal with an enum argument" do
58
+ describe 'for a signal with an enum argument' do
56
59
  let(:signal_info) {
57
- get_signal_introspection_data "Gio", "MountOperation", "reply" }
60
+ get_signal_introspection_data 'Gio', 'MountOperation', 'reply'
61
+ }
58
62
 
59
- it "returns a valid mapping method" do
63
+ it 'returns a valid mapping method' do
60
64
  expected = <<-CODE.reset_indentation
61
65
  def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
62
66
  _instance, result = param_values.map(&:get_value_plain)
@@ -70,11 +74,12 @@ describe GirFFI::Builders::SignalClosureBuilder do
70
74
  end
71
75
  end
72
76
 
73
- describe "for a signal with a array plus length arguments" do
77
+ describe 'for a signal with a array plus length arguments' do
74
78
  let(:signal_info) {
75
- get_signal_introspection_data "Regress", "TestObj", "sig-with-array-len-prop" }
79
+ get_signal_introspection_data 'Regress', 'TestObj', 'sig-with-array-len-prop'
80
+ }
76
81
 
77
- it "returns a valid mapping method" do
82
+ it 'returns a valid mapping method' do
78
83
  skip unless signal_info
79
84
 
80
85
  expected = <<-CODE.reset_indentation
@@ -91,11 +96,12 @@ describe GirFFI::Builders::SignalClosureBuilder do
91
96
  end
92
97
  end
93
98
 
94
- describe "for a signal with a struct argument" do
99
+ describe 'for a signal with a struct argument' do
95
100
  let(:signal_info) {
96
- get_signal_introspection_data "Regress", "TestObj", "test-with-static-scope-arg" }
101
+ get_signal_introspection_data 'Regress', 'TestObj', 'test-with-static-scope-arg'
102
+ }
97
103
 
98
- it "returns a valid mapping method" do
104
+ it 'returns a valid mapping method' do
99
105
  skip unless signal_info
100
106
 
101
107
  expected = <<-CODE.reset_indentation
@@ -111,11 +117,12 @@ describe GirFFI::Builders::SignalClosureBuilder do
111
117
  end
112
118
  end
113
119
 
114
- describe "for a signal returning an array of integers" do
120
+ describe 'for a signal returning an array of integers' do
115
121
  let(:signal_info) {
116
- get_signal_introspection_data "Regress", "TestObj", "sig-with-intarray-ret" }
122
+ get_signal_introspection_data 'Regress', 'TestObj', 'sig-with-intarray-ret'
123
+ }
117
124
 
118
- it "returns a valid mapping method" do
125
+ it 'returns a valid mapping method' do
119
126
  skip unless signal_info
120
127
 
121
128
  expected = <<-CODE.reset_indentation
@@ -1,8 +1,8 @@
1
1
  require 'gir_ffi_test_helper'
2
2
 
3
3
  describe GirFFI::Builders::StructBuilder do
4
- describe "#layout_specification" do
5
- it "returns the correct layout for Regress::TestStructA" do
4
+ describe '#layout_specification' do
5
+ it 'returns the correct layout for Regress::TestStructA' do
6
6
  info = get_introspection_data 'Regress', 'TestStructA'
7
7
  builder = GirFFI::Builders::StructBuilder.new info
8
8
  builder.layout_specification.must_equal [:some_int, :int32, 0,
@@ -12,30 +12,30 @@ describe GirFFI::Builders::StructBuilder do
12
12
  end
13
13
  end
14
14
 
15
- describe "for a struct with a simple layout" do
15
+ describe 'for a struct with a simple layout' do
16
16
  before do
17
17
  @field = Object.new
18
18
 
19
19
  @struct = Object.new
20
20
  stub(@struct).namespace { 'Foo' }
21
21
  stub(@struct).safe_name { 'Bar' }
22
- stub(@struct).fields { [ @field ] }
22
+ stub(@struct).fields { [@field] }
23
23
 
24
24
  @builder = GirFFI::Builders::StructBuilder.new @struct
25
25
  end
26
26
 
27
- it "creates the correct layout specification" do
27
+ it 'creates the correct layout specification' do
28
28
  mock(@field).layout_specification { [:bar, :int32, 0] }
29
29
  spec = @builder.send :layout_specification
30
30
  assert_equal [:bar, :int32, 0], spec
31
31
  end
32
32
  end
33
33
 
34
- describe "for a struct with a layout with a complex type" do
35
- it "does not flatten the complex type specification" do
34
+ describe 'for a struct with a layout with a complex type' do
35
+ it 'does not flatten the complex type specification' do
36
36
  mock(simplefield = Object.new).layout_specification { [:bar, :foo, 0] }
37
37
  mock(complexfield = Object.new).layout_specification { [:baz, [:qux, 2], 0] }
38
- mock(struct = Object.new).fields { [ simplefield, complexfield ] }
38
+ mock(struct = Object.new).fields { [simplefield, complexfield] }
39
39
 
40
40
  stub(struct).safe_name { 'Bar' }
41
41
  stub(struct).namespace { 'Foo' }
@@ -46,8 +46,8 @@ describe GirFFI::Builders::StructBuilder do
46
46
  end
47
47
  end
48
48
 
49
- describe "for a struct without defined fields" do
50
- it "uses a single field of the parent struct type as the default layout" do
49
+ describe 'for a struct without defined fields' do
50
+ it 'uses a single field of the parent struct type as the default layout' do
51
51
  @gir = GObjectIntrospection::IRepository.default
52
52
  @gir.require 'GObject', nil
53
53
 
@@ -1,12 +1,12 @@
1
1
  require 'gir_ffi_test_helper'
2
2
 
3
3
  describe GirFFI::Builders::UnintrospectableBuilder do
4
- describe "building the GLocalFile type" do
4
+ describe 'building the GLocalFile type' do
5
5
  before do
6
6
  # Ensure existence of GLocalFile type
7
7
  GirFFI.setup :Gio
8
8
  unless Gio::Lib.respond_to? :g_file_new_for_path
9
- Gio.setup_method "file_new_for_path"
9
+ Gio.setup_method 'file_new_for_path'
10
10
  end
11
11
  ptr = GirFFI::InPointer.from :utf8, '/'
12
12
  Gio::Lib.g_file_new_for_path(ptr)
@@ -17,30 +17,30 @@ describe GirFFI::Builders::UnintrospectableBuilder do
17
17
  @klass = @bldr.build_class
18
18
  end
19
19
 
20
- it "builds a class" do
20
+ it 'builds a class' do
21
21
  assert_instance_of Class, @klass
22
22
  end
23
23
 
24
- it "builds a class derived from GObject::Object" do
24
+ it 'builds a class derived from GObject::Object' do
25
25
  assert_includes @klass.ancestors, GObject::Object
26
26
  end
27
27
 
28
- it "builds a class derived from Gio::File" do
28
+ it 'builds a class derived from Gio::File' do
29
29
  assert_includes @klass.ancestors, Gio::File
30
30
  end
31
31
 
32
- it "returns the same class when built again" do
32
+ it 'returns the same class when built again' do
33
33
  other_bldr = GirFFI::Builders::UnintrospectableBuilder.new(@info)
34
34
  other_klass = other_bldr.build_class
35
35
 
36
36
  assert_equal @klass, other_klass
37
37
  end
38
38
 
39
- describe "its #find_signal method" do
39
+ describe 'its #find_signal method' do
40
40
  it "raises correct error for a signal that doesn't exist" do
41
41
  msg = nil
42
42
  begin
43
- @bldr.find_signal "foo"
43
+ @bldr.find_signal 'foo'
44
44
  rescue RuntimeError => e
45
45
  msg = e.message
46
46
  end
@@ -4,14 +4,14 @@ describe GirFFI::Builders::UnionBuilder do
4
4
  let(:union_info) { get_introspection_data('GObject', 'TypeCValue') }
5
5
  let(:builder) { GirFFI::Builders::UnionBuilder.new union_info }
6
6
 
7
- describe "#setup_instance_method" do
7
+ describe '#setup_instance_method' do
8
8
  it "returns nil looking for a method that doesn't exist" do
9
9
  builder.setup_instance_method('blub').must_be_nil
10
10
  end
11
11
  end
12
12
 
13
- describe "#layout_specification" do
14
- it "returns the correct layout for GObject::TypeCValue" do
13
+ describe '#layout_specification' do
14
+ it 'returns the correct layout for GObject::TypeCValue' do
15
15
  long_type = FFI.type_size(:long) == 8 ? :int64 : :int32
16
16
  builder.layout_specification.must_equal [:v_int, :int32, 0,
17
17
  :v_long, long_type, 0,
@@ -21,10 +21,9 @@ describe GirFFI::Builders::UnionBuilder do
21
21
  end
22
22
  end
23
23
 
24
- describe "#layout_superclass" do
25
- it "returns FFI::Union" do
24
+ describe '#layout_superclass' do
25
+ it 'returns FFI::Union' do
26
26
  builder.layout_superclass.must_equal FFI::Union
27
27
  end
28
28
  end
29
29
  end
30
-
@@ -3,100 +3,109 @@ require 'gir_ffi_test_helper'
3
3
  GirFFI.setup :GIMarshallingTests
4
4
 
5
5
  describe GirFFI::Builders::UserDefinedBuilder do
6
- let(:klass) { Object.const_set("DerivedClass#{Sequence.next}",
7
- Class.new(GIMarshallingTests::Object)) }
6
+ let(:klass) {
7
+ Object.const_set("DerivedClass#{Sequence.next}",
8
+ Class.new(GIMarshallingTests::Object))
9
+ }
8
10
  let(:builder) { GirFFI::Builders::UserDefinedBuilder.new info }
9
11
  let(:info) { GirFFI::UserDefinedTypeInfo.new klass }
10
12
 
11
- describe "#build_class" do
13
+ describe '#build_class' do
12
14
  before do
13
15
  builder.build_class
14
16
  end
15
17
 
16
- describe "with type info containing one property" do
17
- let(:info) { GirFFI::UserDefinedTypeInfo.new klass do |info|
18
- info.install_property GObject.param_spec_int("foo", "foo bar",
19
- "The Foo Bar Property",
20
- 10, 20, 15,
21
- 3)
22
- end }
18
+ describe 'with type info containing one property' do
19
+ let(:info) {
20
+ GirFFI::UserDefinedTypeInfo.new klass do |info|
21
+ info.install_property GObject.param_spec_int('foo', 'foo bar',
22
+ 'The Foo Bar Property',
23
+ 10, 20, 15,
24
+ 3)
25
+ end
26
+ }
23
27
 
24
- it "registers a type that is bigger than the parent" do
28
+ it 'registers a type that is bigger than the parent' do
25
29
  gtype = klass.get_gtype
26
30
  q = GObject.type_query gtype
27
31
  q.instance_size.must_be :>, GIMarshallingTests::Object::Struct.size
28
32
  end
29
33
 
30
- it "gives the types Struct the fields :parent and :foo" do
34
+ it 'gives the types Struct the fields :parent and :foo' do
31
35
  klass::Struct.members.must_equal [:parent, :foo]
32
36
  end
33
37
 
34
- it "creates accessor functions for the property" do
38
+ it 'creates accessor functions for the property' do
35
39
  obj = klass.new
36
40
  obj.foo = 13
37
41
  obj.foo.must_equal 13
38
42
  end
39
43
 
40
- it "makes the property retrievable using #get_property" do
44
+ it 'makes the property retrievable using #get_property' do
41
45
  obj = klass.new
42
46
  obj.foo = 13
43
- obj.get_property("foo").get_value.must_equal 13
47
+ obj.get_property('foo').get_value.must_equal 13
44
48
  end
45
49
 
46
- it "makes the property settable using #set_property" do
50
+ it 'makes the property settable using #set_property' do
47
51
  obj = klass.new
48
- obj.set_property("foo", 20)
52
+ obj.set_property('foo', 20)
49
53
  obj.foo.must_equal 20
50
54
  end
51
55
  end
52
56
 
53
- describe "with type info containing an overridden g_name" do
54
- let(:info) { GirFFI::UserDefinedTypeInfo.new klass do |info|
55
- info.g_name = "OtherName#{Sequence.next}"
56
- end }
57
+ describe 'with type info containing an overridden g_name' do
58
+ let(:info) {
59
+ GirFFI::UserDefinedTypeInfo.new klass do |info|
60
+ info.g_name = "OtherName#{Sequence.next}"
61
+ end
62
+ }
57
63
 
58
- it "registers a type under the overridden name" do
64
+ it 'registers a type under the overridden name' do
59
65
  registered_name = GObject.type_name(klass.get_gtype)
60
66
  registered_name.must_equal info.g_name
61
67
  registered_name.wont_equal klass.name
62
68
  end
63
69
  end
64
70
 
65
- describe "with type info containing a vfunc" do
66
- let(:info) { GirFFI::UserDefinedTypeInfo.new klass do |info|
67
- info.install_vfunc_implementation :method_int8_in, proc {|instance, in_|
68
- instance.int = in_ }
69
- end }
71
+ describe 'with type info containing a vfunc' do
72
+ let(:info) {
73
+ GirFFI::UserDefinedTypeInfo.new klass do |info|
74
+ info.install_vfunc_implementation :method_int8_in, proc {|instance, in_|
75
+ instance.int = in_
76
+ }
77
+ end
78
+ }
70
79
 
71
- it "allows the vfunc to be called through its invoker" do
80
+ it 'allows the vfunc to be called through its invoker' do
72
81
  obj = klass.new
73
82
  obj.method_int8_in 12
74
83
  obj.int.must_equal 12
75
84
  end
76
85
  end
77
86
 
78
- describe "with type info containing a vfunc from an included Interface" do
87
+ describe 'with type info containing a vfunc from an included Interface' do
79
88
  let(:info) do
80
89
  klass.class_eval { include GIMarshallingTests::Interface }
81
90
  GirFFI::UserDefinedTypeInfo.new klass do |info|
82
91
  info.install_vfunc_implementation :test_int8_in,
83
- proc {|instance, in_| instance.int = in_ }
92
+ proc { |instance, in_| instance.int = in_ }
84
93
  end
85
94
  end
86
95
 
87
- it "marks the type as conforming to the included Interface" do
96
+ it 'marks the type as conforming to the included Interface' do
88
97
  iface_gtype = GIMarshallingTests::Interface.get_gtype
89
98
  GObject.type_interfaces(klass.get_gtype).to_a.must_equal [iface_gtype]
90
99
  end
91
100
 
92
- it "allows the vfunc to be called through its invoker" do
101
+ it 'allows the vfunc to be called through its invoker' do
93
102
  obj = klass.new
94
103
  obj.test_int8_in 12
95
104
  obj.int.must_equal 12
96
105
  end
97
106
  end
98
107
 
99
- it "does not attempt to register a registered class" do
108
+ it 'does not attempt to register a registered class' do
100
109
  gtype = klass.get_gtype
101
110
  other_builder = GirFFI::Builders::UserDefinedBuilder.new info
102
111
  other_builder.build_class
@@ -3,18 +3,19 @@ require 'gir_ffi_test_helper'
3
3
  describe GirFFI::Builders::VFuncBuilder do
4
4
  let(:builder) { GirFFI::Builders::VFuncBuilder.new vfunc_info }
5
5
 
6
- describe "#mapping_method_definition" do
6
+ describe '#mapping_method_definition' do
7
7
  let(:result) { builder.mapping_method_definition }
8
8
 
9
9
  before do
10
10
  skip unless vfunc_info
11
11
  end
12
12
 
13
- describe "for a vfunc with only one argument" do
13
+ describe 'for a vfunc with only one argument' do
14
14
  let(:vfunc_info) {
15
- get_vfunc_introspection_data "GIMarshallingTests", "Object", "method_int8_in" }
15
+ get_vfunc_introspection_data 'GIMarshallingTests', 'Object', 'method_int8_in'
16
+ }
16
17
 
17
- it "returns a valid mapping method including receiver" do
18
+ it 'returns a valid mapping method including receiver' do
18
19
  expected = <<-CODE.reset_indentation
19
20
  def self.call_with_argument_mapping(_proc, _instance, in_)
20
21
  _v1 = GIMarshallingTests::Object.wrap(_instance)
@@ -27,11 +28,12 @@ describe GirFFI::Builders::VFuncBuilder do
27
28
  end
28
29
  end
29
30
 
30
- describe "for a vfunc returning an enum" do
31
+ describe 'for a vfunc returning an enum' do
31
32
  let(:vfunc_info) {
32
- get_vfunc_introspection_data "GIMarshallingTests", "Object", "vfunc_return_enum" }
33
+ get_vfunc_introspection_data 'GIMarshallingTests', 'Object', 'vfunc_return_enum'
34
+ }
33
35
 
34
- it "returns a valid mapping method including receiver" do
36
+ it 'returns a valid mapping method including receiver' do
35
37
  expected = <<-CODE.reset_indentation
36
38
  def self.call_with_argument_mapping(_proc, _instance)
37
39
  _v1 = GIMarshallingTests::Object.wrap(_instance)
@@ -45,11 +47,12 @@ describe GirFFI::Builders::VFuncBuilder do
45
47
  end
46
48
  end
47
49
 
48
- describe "for a vfunc with a callback argument" do
50
+ describe 'for a vfunc with a callback argument' do
49
51
  let(:vfunc_info) {
50
- get_vfunc_introspection_data "GIMarshallingTests", "Object", "vfunc_with_callback" }
52
+ get_vfunc_introspection_data 'GIMarshallingTests', 'Object', 'vfunc_with_callback'
53
+ }
51
54
 
52
- it "returns a valid mapping method including receiver" do
55
+ it 'returns a valid mapping method including receiver' do
53
56
  expected = <<-CODE.reset_indentation
54
57
  def self.call_with_argument_mapping(_proc, _instance, callback, callback_data)
55
58
  _v1 = GIMarshallingTests::Object.wrap(_instance)
@@ -63,12 +66,13 @@ describe GirFFI::Builders::VFuncBuilder do
63
66
  end
64
67
  end
65
68
 
66
- describe "for a vfunc with an out argument allocated by them, the caller" do
69
+ describe 'for a vfunc with an out argument allocated by them, the caller' do
67
70
  let(:vfunc_info) {
68
- get_vfunc_introspection_data("GIMarshallingTests", "Object",
69
- "method_int8_arg_and_out_caller") }
71
+ get_vfunc_introspection_data('GIMarshallingTests', 'Object',
72
+ 'method_int8_arg_and_out_caller')
73
+ }
70
74
 
71
- it "returns a valid mapping method including receiver" do
75
+ it 'returns a valid mapping method including receiver' do
72
76
  expected = <<-CODE.reset_indentation
73
77
  def self.call_with_argument_mapping(_proc, _instance, arg, out)
74
78
  _v1 = GIMarshallingTests::Object.wrap(_instance)
@@ -83,12 +87,13 @@ describe GirFFI::Builders::VFuncBuilder do
83
87
  end
84
88
  end
85
89
 
86
- describe "for a vfunc with an out argument allocated by us, the callee" do
90
+ describe 'for a vfunc with an out argument allocated by us, the callee' do
87
91
  let(:vfunc_info) {
88
- get_vfunc_introspection_data("GIMarshallingTests", "Object",
89
- "method_int8_arg_and_out_callee") }
92
+ get_vfunc_introspection_data('GIMarshallingTests', 'Object',
93
+ 'method_int8_arg_and_out_callee')
94
+ }
90
95
 
91
- it "returns a valid mapping method including receiver" do
96
+ it 'returns a valid mapping method including receiver' do
92
97
  expected = <<-CODE.reset_indentation
93
98
  def self.call_with_argument_mapping(_proc, _instance, arg, out)
94
99
  _v1 = GIMarshallingTests::Object.wrap(_instance)
@@ -103,13 +108,13 @@ describe GirFFI::Builders::VFuncBuilder do
103
108
  end
104
109
  end
105
110
 
106
- describe "for a vfunc with an error argument" do
111
+ describe 'for a vfunc with an error argument' do
107
112
  let(:vfunc_info) {
108
- get_vfunc_introspection_data("GIMarshallingTests", "Object",
109
- "vfunc_meth_with_err")
113
+ get_vfunc_introspection_data('GIMarshallingTests', 'Object',
114
+ 'vfunc_meth_with_err')
110
115
  }
111
116
 
112
- it "returns a valid mapping method including receiver" do
117
+ it 'returns a valid mapping method including receiver' do
113
118
  expected = <<-CODE.reset_indentation
114
119
  def self.call_with_argument_mapping(_proc, _instance, x, _error)
115
120
  _v1 = GIMarshallingTests::Object.wrap(_instance)
@@ -129,35 +134,37 @@ describe GirFFI::Builders::VFuncBuilder do
129
134
  end
130
135
  end
131
136
 
132
- describe "#argument_ffi_types" do
137
+ describe '#argument_ffi_types' do
133
138
  let(:result) { builder.argument_ffi_types }
134
139
 
135
140
  before do
136
141
  skip unless vfunc_info
137
142
  end
138
143
 
139
- describe "for a vfunc with only one argument" do
144
+ describe 'for a vfunc with only one argument' do
140
145
  let(:vfunc_info) {
141
- get_vfunc_introspection_data "GIMarshallingTests", "Object", "method_int8_in" }
146
+ get_vfunc_introspection_data 'GIMarshallingTests', 'Object', 'method_int8_in'
147
+ }
142
148
 
143
- it "returns the correct FFI types including :pointer for the receiver" do
149
+ it 'returns the correct FFI types including :pointer for the receiver' do
144
150
  result.must_equal [:pointer, :int8]
145
151
  end
146
152
  end
147
153
  end
148
154
 
149
- describe "#return_ffi_type" do
155
+ describe '#return_ffi_type' do
150
156
  let(:result) { builder.return_ffi_type }
151
157
 
152
158
  before do
153
159
  skip unless vfunc_info
154
160
  end
155
161
 
156
- describe "for a vfunc returning an object" do
162
+ describe 'for a vfunc returning an object' do
157
163
  let(:vfunc_info) {
158
- get_vfunc_introspection_data "GIMarshallingTests", "Object", "vfunc_return_object_transfer_full" }
164
+ get_vfunc_introspection_data 'GIMarshallingTests', 'Object', 'vfunc_return_object_transfer_full'
165
+ }
159
166
 
160
- it "returns :pointer" do
167
+ it 'returns :pointer' do
161
168
  result.must_equal :pointer
162
169
  end
163
170
  end
@@ -1,11 +1,10 @@
1
1
  require 'gir_ffi_test_helper'
2
2
 
3
3
  describe GirFFI::CallbackBase do
4
- describe ".store_callback" do
5
- it "stores the passed in proc in CALLBACKS" do
6
- GirFFI::CallbackBase.store_callback "some-callback"
7
- GirFFI::CallbackBase::CALLBACKS.last.must_equal "some-callback"
4
+ describe '.store_callback' do
5
+ it 'stores the passed in proc in CALLBACKS' do
6
+ GirFFI::CallbackBase.store_callback 'some-callback'
7
+ GirFFI::CallbackBase::CALLBACKS.last.must_equal 'some-callback'
8
8
  end
9
9
  end
10
10
  end
11
-