gir_ffi 0.15.3 → 0.15.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +15 -0
  3. data/README.md +5 -6
  4. data/TODO.md +14 -35
  5. data/docs/Documentation.md +6 -0
  6. data/docs/Subclassing.md +38 -0
  7. data/lib/ffi-glib.rb +8 -3
  8. data/lib/ffi-glib/byte_array.rb +2 -1
  9. data/lib/ffi-glib/destroy_notify.rb +2 -2
  10. data/lib/ffi-glib/hash_table.rb +1 -2
  11. data/lib/ffi-glib/list.rb +11 -5
  12. data/lib/ffi-glib/list_methods.rb +12 -0
  13. data/lib/ffi-glib/s_list.rb +10 -4
  14. data/lib/ffi-gobject.rb +0 -3
  15. data/lib/ffi-gobject/object.rb +77 -73
  16. data/lib/ffi-gobject/object_class.rb +1 -1
  17. data/lib/ffi-gobject/value.rb +107 -108
  18. data/lib/ffi-gobject_introspection/i_base_info.rb +20 -19
  19. data/lib/gir_ffi-base/gobject/lib.rb +4 -0
  20. data/lib/gir_ffi/array_element_convertor.rb +1 -2
  21. data/lib/gir_ffi/boxed_base.rb +1 -5
  22. data/lib/gir_ffi/builder.rb +1 -1
  23. data/lib/gir_ffi/builder_helper.rb +7 -4
  24. data/lib/gir_ffi/builders/base_argument_builder.rb +2 -2
  25. data/lib/gir_ffi/builders/base_method_builder.rb +1 -1
  26. data/lib/gir_ffi/builders/base_type_builder.rb +1 -1
  27. data/lib/gir_ffi/builders/callback_argument_builder.rb +2 -0
  28. data/lib/gir_ffi/builders/callback_builder.rb +14 -12
  29. data/lib/gir_ffi/builders/callback_return_value_builder.rb +4 -6
  30. data/lib/gir_ffi/builders/class_struct_builder.rb +24 -0
  31. data/lib/gir_ffi/builders/enum_builder.rb +3 -3
  32. data/lib/gir_ffi/builders/interface_builder.rb +3 -1
  33. data/lib/gir_ffi/builders/mapping_method_builder.rb +1 -1
  34. data/lib/gir_ffi/builders/marshalling_method_builder.rb +5 -2
  35. data/lib/gir_ffi/builders/method_template.rb +4 -4
  36. data/lib/gir_ffi/builders/null_argument_builder.rb +0 -2
  37. data/lib/gir_ffi/builders/null_return_value_builder.rb +0 -2
  38. data/lib/gir_ffi/builders/object_builder.rb +16 -6
  39. data/lib/gir_ffi/builders/property_builder.rb +1 -2
  40. data/lib/gir_ffi/builders/signal_closure_builder.rb +3 -5
  41. data/lib/gir_ffi/builders/struct_builder.rb +5 -5
  42. data/lib/gir_ffi/builders/user_defined_builder.rb +8 -1
  43. data/lib/gir_ffi/builders/vfunc_argument_builder.rb +1 -1
  44. data/lib/gir_ffi/callback_base.rb +3 -3
  45. data/lib/gir_ffi/core.rb +17 -2
  46. data/lib/gir_ffi/glib_error.rb +1 -2
  47. data/lib/gir_ffi/in_pointer.rb +7 -0
  48. data/lib/gir_ffi/object_base.rb +27 -0
  49. data/lib/gir_ffi/return_value_info.rb +1 -2
  50. data/lib/gir_ffi/struct_base.rb +1 -9
  51. data/lib/gir_ffi/struct_like_base.rb +9 -5
  52. data/lib/gir_ffi/unintrospectable_type_info.rb +1 -1
  53. data/lib/gir_ffi/union_base.rb +1 -9
  54. data/lib/gir_ffi/user_defined_object_info.rb +3 -2
  55. data/lib/gir_ffi/version.rb +1 -1
  56. data/lib/gir_ffi/vfunc_implementation.rb +1 -0
  57. metadata +86 -136
  58. data/Gemfile +0 -14
  59. data/Rakefile +0 -9
  60. data/tasks/test.rake +0 -204
  61. data/test/base_test_helper.rb +0 -70
  62. data/test/ffi-glib/array_test.rb +0 -203
  63. data/test/ffi-glib/byte_array_test.rb +0 -28
  64. data/test/ffi-glib/bytes_test.rb +0 -61
  65. data/test/ffi-glib/closure_test.rb +0 -38
  66. data/test/ffi-glib/destroy_notify_test.rb +0 -18
  67. data/test/ffi-glib/hash_table_test.rb +0 -68
  68. data/test/ffi-glib/list_test.rb +0 -86
  69. data/test/ffi-glib/main_loop_test.rb +0 -53
  70. data/test/ffi-glib/ptr_array_test.rb +0 -112
  71. data/test/ffi-glib/ruby_closure_test.rb +0 -62
  72. data/test/ffi-glib/s_list_test.rb +0 -76
  73. data/test/ffi-glib/strv_test.rb +0 -60
  74. data/test/ffi-glib/variant_test.rb +0 -12
  75. data/test/ffi-gobject/gobject_test.rb +0 -76
  76. data/test/ffi-gobject/object_class_test.rb +0 -31
  77. data/test/ffi-gobject/object_test.rb +0 -123
  78. data/test/ffi-gobject/param_spec_test.rb +0 -32
  79. data/test/ffi-gobject/value_test.rb +0 -390
  80. data/test/ffi-gobject_introspection/gobject_type_init_test.rb +0 -26
  81. data/test/ffi-gobject_introspection/i_base_info_test.rb +0 -52
  82. data/test/ffi-gobject_introspection/i_constant_info_test.rb +0 -29
  83. data/test/ffi-gobject_introspection/i_enum_info_test.rb +0 -18
  84. data/test/ffi-gobject_introspection/i_function_info_test.rb +0 -6
  85. data/test/ffi-gobject_introspection/i_interface_info_test.rb +0 -23
  86. data/test/ffi-gobject_introspection/i_object_info_test.rb +0 -49
  87. data/test/ffi-gobject_introspection/i_property_info_test.rb +0 -47
  88. data/test/ffi-gobject_introspection/i_registered_type_info_test.rb +0 -27
  89. data/test/ffi-gobject_introspection/i_repository_test.rb +0 -81
  90. data/test/ffi-gobject_introspection/i_struct_info_test.rb +0 -23
  91. data/test/ffi-gobject_introspection/i_type_info_test.rb +0 -30
  92. data/test/ffi-gobject_introspection/i_union_info_test.rb +0 -17
  93. data/test/ffi-gobject_introspection/i_vfunc_info_test.rb +0 -41
  94. data/test/ffi-gobject_introspection/lib_test.rb +0 -13
  95. data/test/ffi-gobject_introspection/strv_test.rb +0 -46
  96. data/test/ffi-gobject_test.rb +0 -153
  97. data/test/gir_ffi/allocation_helper_test.rb +0 -36
  98. data/test/gir_ffi/arg_helper_test.rb +0 -146
  99. data/test/gir_ffi/boolean_test.rb +0 -43
  100. data/test/gir_ffi/boxed_base_test.rb +0 -65
  101. data/test/gir_ffi/builder_test.rb +0 -168
  102. data/test/gir_ffi/builders/argument_builder_test.rb +0 -691
  103. data/test/gir_ffi/builders/base_argument_builder_test.rb +0 -6
  104. data/test/gir_ffi/builders/callback_argument_builder_test.rb +0 -130
  105. data/test/gir_ffi/builders/callback_builder_test.rb +0 -117
  106. data/test/gir_ffi/builders/callback_return_value_builder_test.rb +0 -84
  107. data/test/gir_ffi/builders/constant_builder_test.rb +0 -6
  108. data/test/gir_ffi/builders/constructor_builder_test.rb +0 -39
  109. data/test/gir_ffi/builders/enum_builder_test.rb +0 -23
  110. data/test/gir_ffi/builders/field_builder_test.rb +0 -140
  111. data/test/gir_ffi/builders/function_builder_test.rb +0 -570
  112. data/test/gir_ffi/builders/initializer_builder_test.rb +0 -56
  113. data/test/gir_ffi/builders/interface_builder_test.rb +0 -32
  114. data/test/gir_ffi/builders/module_builder_test.rb +0 -43
  115. data/test/gir_ffi/builders/object_builder_test.rb +0 -98
  116. data/test/gir_ffi/builders/property_builder_test.rb +0 -161
  117. data/test/gir_ffi/builders/registered_type_builder_test.rb +0 -54
  118. data/test/gir_ffi/builders/return_value_builder_test.rb +0 -444
  119. data/test/gir_ffi/builders/signal_closure_builder_test.rb +0 -199
  120. data/test/gir_ffi/builders/struct_builder_test.rb +0 -96
  121. data/test/gir_ffi/builders/unintrospectable_boxed_builder_test.rb +0 -29
  122. data/test/gir_ffi/builders/unintrospectable_builder_test.rb +0 -84
  123. data/test/gir_ffi/builders/union_builder_test.rb +0 -28
  124. data/test/gir_ffi/builders/user_defined_builder_test.rb +0 -528
  125. data/test/gir_ffi/builders/vfunc_argument_builder_test.rb +0 -107
  126. data/test/gir_ffi/builders/vfunc_builder_test.rb +0 -245
  127. data/test/gir_ffi/callback_base_test.rb +0 -22
  128. data/test/gir_ffi/class_base_test.rb +0 -171
  129. data/test/gir_ffi/core_test.rb +0 -99
  130. data/test/gir_ffi/enum_base_test.rb +0 -43
  131. data/test/gir_ffi/error_type_info_test.rb +0 -50
  132. data/test/gir_ffi/ffi_ext/pointer_test.rb +0 -22
  133. data/test/gir_ffi/g_type_test.rb +0 -31
  134. data/test/gir_ffi/in_pointer_test.rb +0 -203
  135. data/test/gir_ffi/info_ext/i_callable_info_test.rb +0 -26
  136. data/test/gir_ffi/info_ext/i_callback_info_test.rb +0 -22
  137. data/test/gir_ffi/info_ext/i_field_info_test.rb +0 -37
  138. data/test/gir_ffi/info_ext/i_function_info_test.rb +0 -74
  139. data/test/gir_ffi/info_ext/i_signal_info_test.rb +0 -32
  140. data/test/gir_ffi/info_ext/i_type_info_test.rb +0 -712
  141. data/test/gir_ffi/info_ext/i_unresolved_info_test.rb +0 -19
  142. data/test/gir_ffi/info_ext/safe_constant_name_test.rb +0 -26
  143. data/test/gir_ffi/info_ext/safe_function_name_test.rb +0 -26
  144. data/test/gir_ffi/interface_base_test.rb +0 -20
  145. data/test/gir_ffi/method_stubber_test.rb +0 -67
  146. data/test/gir_ffi/object_base_test.rb +0 -64
  147. data/test/gir_ffi/object_store_test.rb +0 -41
  148. data/test/gir_ffi/receiver_argument_info_test.rb +0 -33
  149. data/test/gir_ffi/sized_array_test.rb +0 -206
  150. data/test/gir_ffi/struct_base_test.rb +0 -23
  151. data/test/gir_ffi/struct_like_base_test.rb +0 -167
  152. data/test/gir_ffi/type_map_test.rb +0 -17
  153. data/test/gir_ffi/unintrospectable_type_info_test.rb +0 -121
  154. data/test/gir_ffi/union_base_test.rb +0 -23
  155. data/test/gir_ffi/user_defined_object_info_test.rb +0 -119
  156. data/test/gir_ffi/user_defined_property_info_test.rb +0 -39
  157. data/test/gir_ffi/variable_name_generator_test.rb +0 -18
  158. data/test/gir_ffi/version_test.rb +0 -9
  159. data/test/gir_ffi/zero_terminated_test.rb +0 -108
  160. data/test/gir_ffi_test_helper.rb +0 -84
  161. data/test/integration/callback_exceptions_test.rb +0 -59
  162. data/test/integration/derived_classes_test.rb +0 -54
  163. data/test/integration/generated_everything_test.rb +0 -453
  164. data/test/integration/generated_gimarshallingtests_test.rb +0 -3109
  165. data/test/integration/generated_gio_test.rb +0 -116
  166. data/test/integration/generated_glib_test.rb +0 -10
  167. data/test/integration/generated_gobject_test.rb +0 -124
  168. data/test/integration/generated_gst_test.rb +0 -38
  169. data/test/integration/generated_gtk_source_test.rb +0 -21
  170. data/test/integration/generated_gtop_test.rb +0 -22
  171. data/test/integration/generated_pango_ft2_test.rb +0 -17
  172. data/test/integration/generated_pango_test.rb +0 -24
  173. data/test/integration/generated_regress_test.rb +0 -4076
  174. data/test/integration/generated_secret_test.rb +0 -14
  175. data/test/integration/generated_utility_test.rb +0 -174
  176. data/test/integration/generated_warnlib_test.rb +0 -45
  177. data/test/integration/method_lookup_test.rb +0 -34
  178. data/test/introspection_test_helper.rb +0 -94
  179. data/test/lib/Makefile.am +0 -110
  180. data/test/lib/autogen.sh +0 -4
  181. data/test/lib/configure.ac +0 -34
  182. data/test/lib/m4/jhflags.m4 +0 -21
  183. data/test/minitest/stats_plugin.rb +0 -30
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "gir_ffi_test_helper"
4
- require "gir_ffi/user_defined_property_info"
5
-
6
- describe GirFFI::UserDefinedPropertyInfo do
7
- let(:pspec) do
8
- GObject.param_spec_int("foo-bar", "foo bar",
9
- "Foo Bar",
10
- 1, 3, 2,
11
- readable: true, writable: true)
12
- end
13
- let(:container) { Object.new }
14
- let(:info) { GirFFI::UserDefinedPropertyInfo.new pspec, container, 24 }
15
-
16
- describe "#param_spec" do
17
- it "returns the passed in parameter specification" do
18
- _(info.param_spec).must_equal pspec
19
- end
20
- end
21
-
22
- describe "#name" do
23
- it "returns the accessor name from the parameter specification" do
24
- _(info.name).must_equal "foo_bar"
25
- end
26
- end
27
-
28
- describe "#ffi_type" do
29
- it "returns the ffi type corresponding to the type tag" do
30
- _(info.ffi_type).must_equal :int
31
- end
32
- end
33
-
34
- describe "#field_type.tag" do
35
- it "returns the mapped type symbol" do
36
- _(info.field_type.tag).must_equal :gint
37
- end
38
- end
39
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "gir_ffi_test_helper"
4
-
5
- require "gir_ffi/variable_name_generator"
6
-
7
- describe GirFFI::VariableNameGenerator do
8
- describe "#new_var" do
9
- it "generates a sequence of predictable variable names" do
10
- gen = GirFFI::VariableNameGenerator.new
11
-
12
- assert_equal "_v1", gen.new_var
13
- assert_equal "_v2", gen.new_var
14
- assert_equal "_v3", gen.new_var
15
- assert_equal "_v4", gen.new_var
16
- end
17
- end
18
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "gir_ffi_test_helper"
4
-
5
- describe "GirFFI::VERSION" do
6
- it "is set to a valid version number" do
7
- _(GirFFI::VERSION).must_match(/\d+\.\d+\.\d+/)
8
- end
9
- end
@@ -1,108 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "gir_ffi_test_helper"
4
-
5
- describe GirFFI::ZeroTerminated do
6
- describe ".from" do
7
- let(:result) { GirFFI::ZeroTerminated.from :int32, [1, 2, 3] }
8
-
9
- it "converts the passed array into a zero-terminated c array" do
10
- ptr = result.to_ptr
11
- _(ptr.read_array_of_int32(4)).must_equal [1, 2, 3, 0]
12
- end
13
-
14
- it "returns a GirFFI::ZeroTerminated object" do
15
- _(result).must_be_instance_of GirFFI::ZeroTerminated
16
- end
17
-
18
- it "works for Regress::TestEnum from numbers" do
19
- GirFFI.setup :Regress
20
- enum_arr = GirFFI::ZeroTerminated.from Regress::TestEnum, [1, -1, 48]
21
- ptr = enum_arr.to_ptr
22
- _(ptr.read_array_of_int32(4)).must_equal [1, -1, 48, 0]
23
- end
24
-
25
- it "works for Regress::TestEnum from symbols" do
26
- GirFFI.setup :Regress
27
- enum_arr = GirFFI::ZeroTerminated.from Regress::TestEnum, [:value2, :value3, :value4]
28
- ptr = enum_arr.to_ptr
29
- _(ptr.read_array_of_int32(4)).must_equal [1, -1, 48, 0]
30
- end
31
- end
32
-
33
- describe ".wrap" do
34
- it "wraps the given type and pointer" do
35
- ptr = GirFFI::InPointer.from_array :int32, [1, 2, 3, 0]
36
- zt = GirFFI::ZeroTerminated.wrap :foo, ptr
37
- _(zt.element_type).must_equal :foo
38
- _(zt.to_ptr).must_equal ptr
39
- end
40
- end
41
-
42
- describe "#each" do
43
- it "yields each element" do
44
- zt = GirFFI::ZeroTerminated.from :int32, [1, 2, 3]
45
- arr = []
46
- zt.each do |int|
47
- arr << int
48
- end
49
- _(arr).must_equal [1, 2, 3]
50
- end
51
-
52
- it "yields zero times for a ZeroTerminated wrapping a null pointer" do
53
- zt = GirFFI::ZeroTerminated.wrap :int32, FFI::Pointer.new(0)
54
- zt.each do |_str|
55
- flunk
56
- end
57
- end
58
-
59
- it "works for :int8" do
60
- zt = GirFFI::ZeroTerminated.from :int8, [1, 2, 3]
61
- arr = []
62
- zt.each do |int|
63
- arr << int
64
- end
65
- _(arr).must_equal [1, 2, 3]
66
- end
67
- end
68
-
69
- describe "#==" do
70
- it "returns true when comparing to an array with the same elements" do
71
- zero_terminated = GirFFI::ZeroTerminated.from :int32, [1, 2, 3]
72
-
73
- _(zero_terminated == [1, 2, 3]).must_equal true
74
- end
75
-
76
- it "returns false when comparing to an array with different elements" do
77
- zero_terminated = GirFFI::ZeroTerminated.from :int32, [1, 2, 3]
78
-
79
- _(zero_terminated == [1, 2]).must_equal false
80
- end
81
-
82
- it "returns true when comparing to a zero-terminated array with the same elements" do
83
- zero_terminated = GirFFI::ZeroTerminated.from :int32, [1, 2, 3]
84
- other = GirFFI::ZeroTerminated.from :int32, [1, 2, 3]
85
-
86
- _(zero_terminated == other).must_equal true
87
- end
88
-
89
- it "returns false when comparing to a zero-terminated array with different elements" do
90
- zero_terminated = GirFFI::ZeroTerminated.from :int32, [1, 2, 3]
91
- other = GirFFI::ZeroTerminated.from :int32, [1, 2]
92
-
93
- _(zero_terminated == other).must_equal false
94
- end
95
- end
96
-
97
- it "includes Enumerable" do
98
- _(GirFFI::ZeroTerminated).must_include Enumerable
99
- end
100
-
101
- describe "#to_a" do
102
- it "works for Regress::TestEnum" do
103
- GirFFI.setup :Regress
104
- enum_arr = GirFFI::ZeroTerminated.from Regress::TestEnum, [1, 48, -1]
105
- _(enum_arr.to_a).must_equal [:value2, :value4, :value3]
106
- end
107
- end
108
- end
@@ -1,84 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "introspection_test_helper"
4
-
5
- require "gir_ffi"
6
-
7
- # Global sequence provider. Needed to make unique class names.
8
- class Sequence
9
- def self.next
10
- @seq ||= 0
11
- @seq += + 1
12
- end
13
- end
14
-
15
- module GirFFITestExtensions
16
- SAVED_MODULES = {}
17
-
18
- def save_module(name)
19
- return unless Object.const_defined? name
20
-
21
- puts "Saving #{name} over existing" if SAVED_MODULES.key? name
22
- SAVED_MODULES[name] = Object.const_get name
23
- Object.send(:remove_const, name)
24
- end
25
-
26
- def restore_module(name)
27
- Object.send(:remove_const, name) if Object.const_defined? name
28
- return unless SAVED_MODULES.key? name
29
-
30
- Object.const_set name, SAVED_MODULES[name]
31
- SAVED_MODULES.delete name
32
- end
33
-
34
- def object_ref_count(ptr)
35
- GObject::Object::Struct.new(ptr.to_ptr)[:ref_count]
36
- end
37
-
38
- def max_for_unsigned_type(type)
39
- (1 << (FFI.type_size(type) * 8)) - 1
40
- end
41
-
42
- def max_for_type(type)
43
- (1 << (FFI.type_size(type) * 8 - 1)) - 1
44
- end
45
-
46
- def min_for_type(type)
47
- ~max_for_type(type)
48
- end
49
-
50
- def max_long
51
- max_for_type :long
52
- end
53
-
54
- def min_long
55
- min_for_type :long
56
- end
57
-
58
- def max_size_t
59
- max_for_unsigned_type :size_t
60
- end
61
-
62
- def max_ssize_t
63
- # FFI has no :ssize_t, but it's the same number of bits as :size_t
64
- max_for_type :size_t
65
- end
66
-
67
- def min_ssize_t
68
- min_for_type :size_t
69
- end
70
-
71
- def max_ushort
72
- max_for_unsigned_type :ushort
73
- end
74
-
75
- def max_uint
76
- max_for_unsigned_type :uint
77
- end
78
-
79
- def max_ulong
80
- max_for_unsigned_type :ulong
81
- end
82
- end
83
-
84
- Minitest::Test.include GirFFITestExtensions
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "gir_ffi_test_helper"
4
-
5
- GirFFI.setup :Regress
6
-
7
- class CallbackTestException < RuntimeError; end
8
-
9
- describe "An exception in a callback" do
10
- describe "for signals" do
11
- let(:object) { Regress::TestSubObj.new }
12
-
13
- before do
14
- object.signal_connect "test" do
15
- raise CallbackTestException, "Boom"
16
- end
17
- end
18
-
19
- describe "when the signal is emitted synchronously" do
20
- it "raises an error" do
21
- _(proc { GObject.signal_emit object, "test" }).must_raise CallbackTestException
22
- end
23
- end
24
-
25
- describe "when the signal is emitted during an event loop" do
26
- it "causes loop run to be terminated with an exception" do
27
- main_loop = GLib::MainLoop.new nil, false
28
-
29
- GLib.timeout_add GLib::PRIORITY_DEFAULT, 1 do
30
- GObject.signal_emit object, "test"
31
- false
32
- end
33
- # Guard against runaway loop
34
- GLib.timeout_add GLib::PRIORITY_DEFAULT, 500 do
35
- main_loop.quit
36
- end
37
- _(proc { main_loop.run }).must_raise CallbackTestException
38
- end
39
- end
40
- end
41
-
42
- describe "for other callbacks" do
43
- describe "when the callback occurs during an event loop" do
44
- it "causes loop run to be terminated with an exception" do
45
- main_loop = GLib::MainLoop.new nil, false
46
-
47
- GLib.timeout_add GLib::PRIORITY_DEFAULT, 1 do
48
- raise CallbackTestException, "Boom"
49
- end
50
- # Guard against runaway loop
51
- GLib.timeout_add GLib::PRIORITY_DEFAULT, 500 do
52
- main_loop.quit
53
- end
54
-
55
- _(proc { main_loop.run }).must_raise CallbackTestException
56
- end
57
- end
58
- end
59
- end
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "gir_ffi_test_helper"
4
-
5
- GirFFI.setup :Regress
6
-
7
- # Tests deriving Ruby classes from GObject classes.
8
- describe "For derived classes" do
9
- describe "setting up methods when first called" do
10
- before do
11
- save_module :GIMarshallingTests
12
- GirFFI.setup :GIMarshallingTests
13
- end
14
-
15
- describe "when an interface is mixed in" do
16
- before do
17
- @klass = Class.new GIMarshallingTests::OverridesObject
18
- @klass.send :include, GIMarshallingTests::Interface
19
- end
20
-
21
- it "finds class methods in the superclass" do
22
- @klass.returnv
23
- end
24
-
25
- it "finds instance methods in the superclass" do
26
- obj = @klass.new
27
- result = obj.method
28
- _(result).must_equal 42
29
- end
30
- end
31
-
32
- after do
33
- restore_module :GIMarshallingTests
34
- end
35
- end
36
-
37
- describe "the initializer" do
38
- it "works if it calls super" do
39
- klass = Class.new Regress::TestSubObj do
40
- attr_reader :animal
41
-
42
- def initialize(animal)
43
- super()
44
- @animal = animal
45
- end
46
- end
47
-
48
- obj = klass.new "dog"
49
- _(obj).must_be_instance_of klass
50
- _(obj.to_ptr).wont_be_nil
51
- _(obj.animal).must_equal "dog"
52
- end
53
- end
54
- end
@@ -1,453 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "gir_ffi_test_helper"
4
-
5
- GirFFI.setup :Everything
6
-
7
- describe Everything do
8
- it "has a working function #const_return_GType" do
9
- _(Everything.const_return_GType).must_equal GObject::TYPE_OBJECT
10
- end
11
-
12
- it "has a working function #const_return_filename" do
13
- _(Everything.const_return_filename).must_equal ""
14
- end
15
-
16
- it "has a working function #const_return_gboolean" do
17
- _(Everything.const_return_gboolean).must_equal false
18
- end
19
-
20
- it "has a working function #const_return_gchar" do
21
- _(Everything.const_return_gchar).must_equal 0
22
- end
23
-
24
- it "has a working function #const_return_gdouble" do
25
- _(Everything.const_return_gdouble).must_equal 0
26
- end
27
-
28
- it "has a working function #const_return_gfloat" do
29
- _(Everything.const_return_gfloat).must_equal 0
30
- end
31
-
32
- it "has a working function #const_return_gint" do
33
- _(Everything.const_return_gint).must_equal 0
34
- end
35
-
36
- it "has a working function #const_return_gint16" do
37
- _(Everything.const_return_gint16).must_equal 0
38
- end
39
-
40
- it "has a working function #const_return_gint32" do
41
- _(Everything.const_return_gint32).must_equal 0
42
- end
43
-
44
- it "has a working function #const_return_gint64" do
45
- _(Everything.const_return_gint64).must_equal 0
46
- end
47
-
48
- it "has a working function #const_return_gint8" do
49
- _(Everything.const_return_gint8).must_equal 0
50
- end
51
-
52
- it "has a working function #const_return_gintptr" do
53
- _(Everything.const_return_gintptr).must_equal 0
54
- end
55
-
56
- it "has a working function #const_return_glong" do
57
- _(Everything.const_return_glong).must_equal 0
58
- end
59
-
60
- it "has a working function #const_return_gpointer" do
61
- skip_below "1.47.1"
62
- _(Everything.const_return_gpointer).must_be :null?
63
- end
64
-
65
- it "has a working function #const_return_gshort" do
66
- _(Everything.const_return_gshort).must_equal 0
67
- end
68
-
69
- it "has a working function #const_return_gsize" do
70
- _(Everything.const_return_gsize).must_equal 0
71
- end
72
-
73
- it "has a working function #const_return_gssize" do
74
- _(Everything.const_return_gssize).must_equal 0
75
- end
76
-
77
- it "has a working function #const_return_guint" do
78
- _(Everything.const_return_guint).must_equal 0
79
- end
80
-
81
- it "has a working function #const_return_guint16" do
82
- _(Everything.const_return_guint16).must_equal 0
83
- end
84
-
85
- it "has a working function #const_return_guint32" do
86
- _(Everything.const_return_guint32).must_equal 0
87
- end
88
-
89
- it "has a working function #const_return_guint64" do
90
- _(Everything.const_return_guint64).must_equal 0
91
- end
92
-
93
- it "has a working function #const_return_guint8" do
94
- _(Everything.const_return_guint8).must_equal 0
95
- end
96
-
97
- it "has a working function #const_return_guintptr" do
98
- _(Everything.const_return_guintptr).must_equal 0
99
- end
100
-
101
- it "has a working function #const_return_gulong" do
102
- _(Everything.const_return_gulong).must_equal 0
103
- end
104
-
105
- it "has a working function #const_return_gunichar" do
106
- _(Everything.const_return_gunichar).must_equal 0
107
- end
108
-
109
- it "has a working function #const_return_gushort" do
110
- _(Everything.const_return_gushort).must_equal 0
111
- end
112
-
113
- it "has a working function #const_return_utf8" do
114
- _(Everything.const_return_utf8).must_equal ""
115
- end
116
-
117
- it "has a working function #nullfunc" do
118
- _(Everything.nullfunc).must_be_nil
119
- end
120
-
121
- it "has a working function #one_outparam_GType" do
122
- _(Everything.one_outparam_GType).must_equal 0
123
- end
124
-
125
- it "has a working function #one_outparam_filename" do
126
- # NOTE: This function stores a null pointer in its output parameter.
127
- _(Everything.one_outparam_filename).must_be_nil
128
- end
129
-
130
- it "has a working function #one_outparam_gboolean" do
131
- _(Everything.one_outparam_gboolean).must_equal false
132
- end
133
-
134
- it "has a working function #one_outparam_gchar" do
135
- skip "GIR gives the incorrect type: utf8 instead of gchar"
136
- _(Everything.one_outparam_gchar).must_equal 0
137
- end
138
-
139
- it "has a working function #one_outparam_gdouble" do
140
- _(Everything.one_outparam_gdouble).must_equal 0
141
- end
142
-
143
- it "has a working function #one_outparam_gfloat" do
144
- _(Everything.one_outparam_gfloat).must_equal 0
145
- end
146
-
147
- it "has a working function #one_outparam_gint" do
148
- _(Everything.one_outparam_gint).must_equal 0
149
- end
150
-
151
- it "has a working function #one_outparam_gint16" do
152
- _(Everything.one_outparam_gint16).must_equal 0
153
- end
154
-
155
- it "has a working function #one_outparam_gint32" do
156
- _(Everything.one_outparam_gint32).must_equal 0
157
- end
158
-
159
- it "has a working function #one_outparam_gint64" do
160
- _(Everything.one_outparam_gint64).must_equal 0
161
- end
162
-
163
- it "has a working function #one_outparam_gint8" do
164
- _(Everything.one_outparam_gint8).must_equal 0
165
- end
166
-
167
- it "has a working function #one_outparam_gintptr" do
168
- _(Everything.one_outparam_gintptr).must_equal 0
169
- end
170
-
171
- it "has a working function #one_outparam_glong" do
172
- _(Everything.one_outparam_glong).must_equal 0
173
- end
174
-
175
- it "has a working function #one_outparam_gpointer" do
176
- skip_below "1.47.1"
177
- _(Everything.one_outparam_gpointer).must_be :null?
178
- end
179
-
180
- it "has a working function #one_outparam_gshort" do
181
- _(Everything.one_outparam_gshort).must_equal 0
182
- end
183
-
184
- it "has a working function #one_outparam_gsize" do
185
- _(Everything.one_outparam_gsize).must_equal 0
186
- end
187
-
188
- it "has a working function #one_outparam_gssize" do
189
- _(Everything.one_outparam_gssize).must_equal 0
190
- end
191
-
192
- it "has a working function #one_outparam_guint" do
193
- _(Everything.one_outparam_guint).must_equal 0
194
- end
195
-
196
- it "has a working function #one_outparam_guint16" do
197
- _(Everything.one_outparam_guint16).must_equal 0
198
- end
199
-
200
- it "has a working function #one_outparam_guint32" do
201
- _(Everything.one_outparam_guint32).must_equal 0
202
- end
203
-
204
- it "has a working function #one_outparam_guint64" do
205
- _(Everything.one_outparam_guint64).must_equal 0
206
- end
207
-
208
- it "has a working function #one_outparam_guint8" do
209
- _(Everything.one_outparam_guint8).must_equal 0
210
- end
211
-
212
- it "has a working function #one_outparam_guintptr" do
213
- _(Everything.one_outparam_guintptr).must_equal 0
214
- end
215
-
216
- it "has a working function #one_outparam_gulong" do
217
- _(Everything.one_outparam_gulong).must_equal 0
218
- end
219
-
220
- it "has a working function #one_outparam_gunichar" do
221
- _(Everything.one_outparam_gunichar).must_equal 0
222
- end
223
-
224
- it "has a working function #one_outparam_gushort" do
225
- _(Everything.one_outparam_gushort).must_equal 0
226
- end
227
-
228
- it "has a working function #one_outparam_utf8" do
229
- # NOTE: This function stores a null pointer in its output parameter.
230
- _(Everything.one_outparam_utf8).must_be_nil
231
- end
232
-
233
- it "has a working function #oneparam_GType" do
234
- _(Everything.oneparam_GType(0)).must_be_nil
235
- end
236
-
237
- it "has a working function #oneparam_filename" do
238
- _(Everything.oneparam_filename("")).must_be_nil
239
- end
240
-
241
- it "has a working function #oneparam_gboolean" do
242
- _(Everything.oneparam_gboolean(false)).must_be_nil
243
- end
244
-
245
- it "has a working function #oneparam_gchar" do
246
- _(Everything.oneparam_gchar(0)).must_be_nil
247
- end
248
-
249
- it "has a working function #oneparam_gdouble" do
250
- _(Everything.oneparam_gdouble(0.0)).must_be_nil
251
- end
252
-
253
- it "has a working function #oneparam_gfloat" do
254
- _(Everything.oneparam_gfloat(0.0)).must_be_nil
255
- end
256
-
257
- it "has a working function #oneparam_gint" do
258
- _(Everything.oneparam_gint(0)).must_be_nil
259
- end
260
-
261
- it "has a working function #oneparam_gint16" do
262
- _(Everything.oneparam_gint16(0)).must_be_nil
263
- end
264
-
265
- it "has a working function #oneparam_gint32" do
266
- _(Everything.oneparam_gint32(0)).must_be_nil
267
- end
268
-
269
- it "has a working function #oneparam_gint64" do
270
- _(Everything.oneparam_gint64(0)).must_be_nil
271
- end
272
-
273
- it "has a working function #oneparam_gint8" do
274
- _(Everything.oneparam_gint8(0)).must_be_nil
275
- end
276
-
277
- it "has a working function #oneparam_gintptr" do
278
- _(Everything.oneparam_gintptr(0)).must_be_nil
279
- end
280
-
281
- it "has a working function #oneparam_glong" do
282
- _(Everything.oneparam_glong(0)).must_be_nil
283
- end
284
-
285
- it "has a working function #oneparam_gpointer" do
286
- skip_below "1.47.1"
287
- _(Everything.oneparam_gpointer(FFI::MemoryPointer.new(:int))).must_be_nil
288
- end
289
-
290
- it "has a working function #oneparam_gshort" do
291
- _(Everything.oneparam_gshort(0)).must_be_nil
292
- end
293
-
294
- it "has a working function #oneparam_gsize" do
295
- _(Everything.oneparam_gsize(0)).must_be_nil
296
- end
297
-
298
- it "has a working function #oneparam_gssize" do
299
- _(Everything.oneparam_gssize(0)).must_be_nil
300
- end
301
-
302
- it "has a working function #oneparam_guint" do
303
- _(Everything.oneparam_guint(0)).must_be_nil
304
- end
305
-
306
- it "has a working function #oneparam_guint16" do
307
- _(Everything.oneparam_guint16(0)).must_be_nil
308
- end
309
-
310
- it "has a working function #oneparam_guint32" do
311
- _(Everything.oneparam_guint32(0)).must_be_nil
312
- end
313
-
314
- it "has a working function #oneparam_guint64" do
315
- _(Everything.oneparam_guint64(0)).must_be_nil
316
- end
317
-
318
- it "has a working function #oneparam_guint8" do
319
- _(Everything.oneparam_guint8(0)).must_be_nil
320
- end
321
-
322
- it "has a working function #oneparam_guintptr" do
323
- _(Everything.oneparam_guintptr(0)).must_be_nil
324
- end
325
-
326
- it "has a working function #oneparam_gulong" do
327
- _(Everything.oneparam_gulong(0)).must_be_nil
328
- end
329
-
330
- it "has a working function #oneparam_gunichar" do
331
- _(Everything.oneparam_gunichar(0)).must_be_nil
332
- end
333
-
334
- it "has a working function #oneparam_gushort" do
335
- _(Everything.oneparam_gushort(0)).must_be_nil
336
- end
337
-
338
- it "has a working function #oneparam_utf8" do
339
- _(Everything.oneparam_utf8("")).must_be_nil
340
- end
341
-
342
- it "has a working function #passthrough_one_GType" do
343
- _(Everything.passthrough_one_GType(GObject::TYPE_OBJECT))
344
- .must_equal GObject::TYPE_OBJECT
345
- end
346
-
347
- it "has a working function #passthrough_one_filename" do
348
- _(Everything.passthrough_one_filename("foo")).must_equal "foo"
349
- end
350
-
351
- it "has a working function #passthrough_one_gboolean" do
352
- _(Everything.passthrough_one_gboolean(true)).must_equal true
353
- end
354
-
355
- it "has a working function #passthrough_one_gchar" do
356
- _(Everything.passthrough_one_gchar(42)).must_equal 42
357
- end
358
-
359
- it "has a working function #passthrough_one_gdouble" do
360
- _(Everything.passthrough_one_gdouble(23.42)).must_equal 23.42
361
- end
362
-
363
- it "has a working function #passthrough_one_gfloat" do
364
- _(Everything.passthrough_one_gfloat(23.42)).must_be_close_to 23.42
365
- end
366
-
367
- it "has a working function #passthrough_one_gint" do
368
- _(Everything.passthrough_one_gint(42)).must_equal 42
369
- end
370
-
371
- it "has a working function #passthrough_one_gint16" do
372
- _(Everything.passthrough_one_gint16(42)).must_equal 42
373
- end
374
-
375
- it "has a working function #passthrough_one_gint32" do
376
- _(Everything.passthrough_one_gint32(42)).must_equal 42
377
- end
378
-
379
- it "has a working function #passthrough_one_gint64" do
380
- _(Everything.passthrough_one_gint64(42)).must_equal 42
381
- end
382
-
383
- it "has a working function #passthrough_one_gint8" do
384
- _(Everything.passthrough_one_gint8(42)).must_equal 42
385
- end
386
-
387
- it "has a working function #passthrough_one_gintptr" do
388
- _(Everything.passthrough_one_gintptr(42)).must_equal 42
389
- end
390
-
391
- it "has a working function #passthrough_one_glong" do
392
- _(Everything.passthrough_one_glong(42)).must_equal 42
393
- end
394
-
395
- it "has a working function #passthrough_one_gpointer" do
396
- skip_below "1.47.1"
397
- ptr = FFI::MemoryPointer.new(:int)
398
- result = Everything.passthrough_one_gpointer(ptr)
399
- _(result).must_be :==, ptr
400
- end
401
-
402
- it "has a working function #passthrough_one_gshort" do
403
- _(Everything.passthrough_one_gshort(42)).must_equal 42
404
- end
405
-
406
- it "has a working function #passthrough_one_gsize" do
407
- _(Everything.passthrough_one_gsize(42)).must_equal 42
408
- end
409
-
410
- it "has a working function #passthrough_one_gssize" do
411
- _(Everything.passthrough_one_gssize(42)).must_equal 42
412
- end
413
-
414
- it "has a working function #passthrough_one_guint" do
415
- _(Everything.passthrough_one_guint(42)).must_equal 42
416
- end
417
-
418
- it "has a working function #passthrough_one_guint16" do
419
- _(Everything.passthrough_one_guint16(42)).must_equal 42
420
- end
421
-
422
- it "has a working function #passthrough_one_guint32" do
423
- _(Everything.passthrough_one_guint32(42)).must_equal 42
424
- end
425
-
426
- it "has a working function #passthrough_one_guint64" do
427
- _(Everything.passthrough_one_guint64(42)).must_equal 42
428
- end
429
-
430
- it "has a working function #passthrough_one_guint8" do
431
- _(Everything.passthrough_one_guint8(42)).must_equal 42
432
- end
433
-
434
- it "has a working function #passthrough_one_guintptr" do
435
- _(Everything.passthrough_one_guintptr(42)).must_equal 42
436
- end
437
-
438
- it "has a working function #passthrough_one_gulong" do
439
- _(Everything.passthrough_one_gulong(42)).must_equal 42
440
- end
441
-
442
- it "has a working function #passthrough_one_gunichar" do
443
- _(Everything.passthrough_one_gunichar(42)).must_equal 42
444
- end
445
-
446
- it "has a working function #passthrough_one_gushort" do
447
- _(Everything.passthrough_one_gushort(42)).must_equal 42
448
- end
449
-
450
- it "has a working function #passthrough_one_utf8" do
451
- _(Everything.passthrough_one_utf8("42")).must_equal "42"
452
- end
453
- end