gir_ffi 0.14.1 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +21 -0
- data/Gemfile +6 -4
- data/README.md +4 -4
- data/Rakefile +5 -5
- data/lib/ffi-glib/array.rb +14 -4
- data/lib/ffi-glib/byte_array.rb +7 -2
- data/lib/ffi-glib/container_class_methods.rb +1 -1
- data/lib/ffi-glib/error.rb +1 -1
- data/lib/ffi-glib/hash_table.rb +3 -3
- data/lib/ffi-glib/list.rb +1 -1
- data/lib/ffi-glib/list_methods.rb +1 -1
- data/lib/ffi-glib/main_loop.rb +3 -3
- data/lib/ffi-glib/ptr_array.rb +30 -8
- data/lib/ffi-glib/s_list.rb +1 -1
- data/lib/ffi-glib/variant.rb +1 -1
- data/lib/ffi-glib.rb +16 -16
- data/lib/ffi-gobject/object.rb +23 -32
- data/lib/ffi-gobject/param_spec.rb +1 -1
- data/lib/ffi-gobject/ruby_closure.rb +2 -2
- data/lib/ffi-gobject/value.rb +37 -28
- data/lib/ffi-gobject.rb +13 -13
- data/lib/ffi-gobject_introspection/gobject_type_init.rb +2 -2
- data/lib/ffi-gobject_introspection/i_arg_info.rb +2 -2
- data/lib/ffi-gobject_introspection/i_base_info.rb +27 -17
- data/lib/ffi-gobject_introspection/i_callable_info.rb +4 -4
- data/lib/ffi-gobject_introspection/i_constant_info.rb +2 -2
- data/lib/ffi-gobject_introspection/i_enum_info.rb +1 -0
- data/lib/ffi-gobject_introspection/i_field_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_function_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_interface_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_object_info.rb +2 -2
- data/lib/ffi-gobject_introspection/i_property_info.rb +2 -2
- data/lib/ffi-gobject_introspection/i_repository.rb +9 -6
- data/lib/ffi-gobject_introspection/i_struct_info.rb +2 -1
- data/lib/ffi-gobject_introspection/i_type_info.rb +13 -7
- data/lib/ffi-gobject_introspection/i_unresolved_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_vfunc_info.rb +1 -1
- data/lib/ffi-gobject_introspection/lib.rb +30 -19
- data/lib/ffi-gobject_introspection/strv.rb +1 -1
- data/lib/ffi-gobject_introspection.rb +20 -20
- data/lib/gir_ffi/allocation_helper.rb +1 -1
- data/lib/gir_ffi/arg_helper.rb +4 -4
- data/lib/gir_ffi/{in_out_pointer.rb → array_element_convertor.rb} +16 -23
- data/lib/gir_ffi/boolean.rb +1 -1
- data/lib/gir_ffi/boxed_base.rb +1 -1
- data/lib/gir_ffi/builder.rb +18 -10
- data/lib/gir_ffi/builders/argument_builder.rb +17 -17
- data/lib/gir_ffi/builders/base_argument_builder.rb +1 -0
- data/lib/gir_ffi/builders/base_method_builder.rb +7 -7
- data/lib/gir_ffi/builders/base_return_value_builder.rb +1 -1
- data/lib/gir_ffi/builders/base_type_builder.rb +1 -1
- data/lib/gir_ffi/builders/c_to_ruby_convertor.rb +5 -5
- data/lib/gir_ffi/builders/callback_argument_builder.rb +8 -8
- data/lib/gir_ffi/builders/callback_builder.rb +3 -3
- data/lib/gir_ffi/builders/callback_return_value_builder.rb +2 -2
- data/lib/gir_ffi/builders/closure_argument_builder.rb +1 -1
- data/lib/gir_ffi/builders/closure_return_value_builder.rb +1 -1
- data/lib/gir_ffi/builders/constant_builder.rb +1 -1
- data/lib/gir_ffi/builders/constructor_builder.rb +9 -9
- data/lib/gir_ffi/builders/enum_builder.rb +2 -2
- data/lib/gir_ffi/builders/field_builder.rb +16 -15
- data/lib/gir_ffi/builders/flags_builder.rb +2 -2
- data/lib/gir_ffi/builders/full_c_to_ruby_convertor.rb +1 -1
- data/lib/gir_ffi/builders/function_builder.rb +11 -5
- data/lib/gir_ffi/builders/initializer_builder.rb +3 -3
- data/lib/gir_ffi/builders/initializer_return_value_builder.rb +2 -2
- data/lib/gir_ffi/builders/interface_builder.rb +2 -2
- data/lib/gir_ffi/builders/mapping_method_builder.rb +9 -9
- data/lib/gir_ffi/builders/marshalling_method_builder.rb +7 -7
- data/lib/gir_ffi/builders/method_template.rb +1 -1
- data/lib/gir_ffi/builders/module_builder.rb +4 -6
- data/lib/gir_ffi/builders/object_builder.rb +6 -6
- data/lib/gir_ffi/builders/property_argument_builder.rb +1 -1
- data/lib/gir_ffi/builders/property_builder.rb +13 -12
- data/lib/gir_ffi/builders/property_return_value_builder.rb +1 -1
- data/lib/gir_ffi/builders/registered_type_builder.rb +14 -5
- data/lib/gir_ffi/builders/return_value_builder.rb +4 -4
- data/lib/gir_ffi/builders/ruby_to_c_convertor.rb +6 -6
- data/lib/gir_ffi/builders/signal_closure_builder.rb +2 -2
- data/lib/gir_ffi/builders/struct_builder.rb +4 -4
- data/lib/gir_ffi/builders/struct_like.rb +1 -1
- data/lib/gir_ffi/builders/type_builder.rb +12 -12
- data/lib/gir_ffi/builders/unintrospectable_boxed_builder.rb +2 -2
- data/lib/gir_ffi/builders/unintrospectable_builder.rb +2 -2
- data/lib/gir_ffi/builders/union_builder.rb +4 -4
- data/lib/gir_ffi/builders/user_defined_builder.rb +2 -2
- data/lib/gir_ffi/builders/vfunc_argument_builder.rb +1 -1
- data/lib/gir_ffi/builders/vfunc_builder.rb +6 -6
- data/lib/gir_ffi/builders/with_layout.rb +2 -2
- data/lib/gir_ffi/callback_base.rb +1 -1
- data/lib/gir_ffi/class_base.rb +5 -5
- data/lib/gir_ffi/core.rb +19 -20
- data/lib/gir_ffi/enum_base.rb +1 -1
- data/lib/gir_ffi/enum_like_base.rb +2 -2
- data/lib/gir_ffi/error_argument_info.rb +2 -2
- data/lib/gir_ffi/error_type_info.rb +1 -1
- data/lib/gir_ffi/ffi_ext/pointer.rb +1 -1
- data/lib/gir_ffi/ffi_ext.rb +1 -1
- data/lib/gir_ffi/flags_base.rb +1 -1
- data/lib/gir_ffi/in_pointer.rb +10 -0
- data/lib/gir_ffi/info_ext/full_type_name.rb +3 -3
- data/lib/gir_ffi/info_ext/i_arg_info.rb +1 -1
- data/lib/gir_ffi/info_ext/i_callable_info.rb +1 -1
- data/lib/gir_ffi/info_ext/i_callback_info.rb +1 -1
- data/lib/gir_ffi/info_ext/i_field_info.rb +1 -1
- data/lib/gir_ffi/info_ext/i_function_info.rb +1 -1
- data/lib/gir_ffi/info_ext/i_property_info.rb +2 -2
- data/lib/gir_ffi/info_ext/i_registered_type_info.rb +4 -5
- data/lib/gir_ffi/info_ext/i_signal_info.rb +7 -3
- data/lib/gir_ffi/info_ext/i_type_info.rb +48 -26
- data/lib/gir_ffi/info_ext/i_unresolved_info.rb +1 -1
- data/lib/gir_ffi/info_ext/i_value_info.rb +2 -2
- data/lib/gir_ffi/info_ext/i_vfunc_info.rb +2 -2
- data/lib/gir_ffi/info_ext/safe_constant_name.rb +8 -8
- data/lib/gir_ffi/info_ext/safe_function_name.rb +2 -2
- data/lib/gir_ffi/info_ext.rb +15 -15
- data/lib/gir_ffi/interface_base.rb +3 -3
- data/lib/gir_ffi/lib_c.rb +1 -1
- data/lib/gir_ffi/method_stubber.rb +1 -1
- data/lib/gir_ffi/module_base.rb +1 -1
- data/lib/gir_ffi/object_base.rb +3 -4
- data/lib/gir_ffi/receiver_argument_info.rb +1 -1
- data/lib/gir_ffi/receiver_type_info.rb +2 -2
- data/lib/gir_ffi/registered_type_base.rb +1 -1
- data/lib/gir_ffi/sized_array.rb +4 -2
- data/lib/gir_ffi/struct.rb +1 -1
- data/lib/gir_ffi/struct_base.rb +1 -1
- data/lib/gir_ffi/type_map.rb +2 -23
- data/lib/gir_ffi/unintrospectable_boxed_info.rb +2 -2
- data/lib/gir_ffi/unintrospectable_type_info.rb +1 -1
- data/lib/gir_ffi/union.rb +1 -1
- data/lib/gir_ffi/union_base.rb +1 -1
- data/lib/gir_ffi/user_defined_object_info.rb +6 -2
- data/lib/gir_ffi/user_defined_property_info.rb +33 -33
- data/lib/gir_ffi/version.rb +1 -1
- data/lib/gir_ffi-base/gobject/lib.rb +3 -2
- data/lib/gir_ffi-base/gobject.rb +26 -25
- data/lib/gir_ffi-base.rb +1 -1
- data/lib/gir_ffi.rb +3 -3
- data/tasks/test.rake +3 -2
- data/test/base_test_helper.rb +16 -9
- data/test/ffi-glib/array_test.rb +71 -56
- data/test/ffi-glib/byte_array_test.rb +13 -7
- data/test/ffi-glib/bytes_test.rb +24 -19
- data/test/ffi-glib/closure_test.rb +11 -11
- data/test/ffi-glib/destroy_notify_test.rb +6 -6
- data/test/ffi-glib/hash_table_test.rb +27 -27
- data/test/ffi-glib/list_test.rb +22 -22
- data/test/ffi-glib/main_loop_test.rb +12 -12
- data/test/ffi-glib/ptr_array_test.rb +39 -39
- data/test/ffi-glib/ruby_closure_test.rb +10 -10
- data/test/ffi-glib/s_list_test.rb +20 -20
- data/test/ffi-glib/strv_test.rb +19 -19
- data/test/ffi-glib/variant_test.rb +5 -5
- data/test/ffi-gobject/gobject_test.rb +48 -44
- data/test/ffi-gobject/object_class_test.rb +8 -8
- data/test/ffi-gobject/object_test.rb +49 -67
- data/test/ffi-gobject/param_spec_test.rb +12 -12
- data/test/ffi-gobject/value_test.rb +145 -125
- data/test/ffi-gobject_introspection/gobject_type_init_test.rb +8 -8
- data/test/ffi-gobject_introspection/i_base_info_test.rb +15 -16
- data/test/ffi-gobject_introspection/i_constant_info_test.rb +9 -13
- data/test/ffi-gobject_introspection/i_enum_info_test.rb +7 -7
- data/test/ffi-gobject_introspection/i_function_info_test.rb +1 -1
- data/test/ffi-gobject_introspection/i_interface_info_test.rb +10 -10
- data/test/ffi-gobject_introspection/i_object_info_test.rb +23 -23
- data/test/ffi-gobject_introspection/i_property_info_test.rb +19 -19
- data/test/ffi-gobject_introspection/i_registered_type_info_test.rb +10 -10
- data/test/ffi-gobject_introspection/i_repository_test.rb +31 -31
- data/test/ffi-gobject_introspection/i_struct_info_test.rb +10 -10
- data/test/ffi-gobject_introspection/i_type_info_test.rb +12 -15
- data/test/ffi-gobject_introspection/i_union_info_test.rb +7 -7
- data/test/ffi-gobject_introspection/i_vfunc_info_test.rb +16 -16
- data/test/ffi-gobject_introspection/lib_test.rb +3 -3
- data/test/ffi-gobject_introspection/strv_test.rb +9 -9
- data/test/ffi-gobject_test.rb +44 -44
- data/test/gir_ffi/allocation_helper_test.rb +13 -13
- data/test/gir_ffi/arg_helper_test.rb +63 -64
- data/test/gir_ffi/boolean_test.rb +20 -20
- data/test/gir_ffi/boxed_base_test.rb +18 -18
- data/test/gir_ffi/builder_test.rb +115 -93
- data/test/gir_ffi/builders/argument_builder_test.rb +280 -286
- data/test/gir_ffi/builders/base_argument_builder_test.rb +1 -1
- data/test/gir_ffi/builders/callback_argument_builder_test.rb +53 -56
- data/test/gir_ffi/builders/callback_builder_test.rb +71 -72
- data/test/gir_ffi/builders/callback_return_value_builder_test.rb +36 -40
- data/test/gir_ffi/builders/constant_builder_test.rb +1 -1
- data/test/gir_ffi/builders/constructor_builder_test.rb +10 -10
- data/test/gir_ffi/builders/enum_builder_test.rb +10 -10
- data/test/gir_ffi/builders/field_builder_test.rb +42 -42
- data/test/gir_ffi/builders/function_builder_test.rb +236 -224
- data/test/gir_ffi/builders/initializer_builder_test.rb +14 -14
- data/test/gir_ffi/builders/interface_builder_test.rb +9 -9
- data/test/gir_ffi/builders/module_builder_test.rb +18 -18
- data/test/gir_ffi/builders/object_builder_test.rb +38 -38
- data/test/gir_ffi/builders/property_builder_test.rb +91 -94
- data/test/gir_ffi/builders/registered_type_builder_test.rb +35 -11
- data/test/gir_ffi/builders/return_value_builder_test.rb +215 -222
- data/test/gir_ffi/builders/signal_closure_builder_test.rb +122 -113
- data/test/gir_ffi/builders/struct_builder_test.rb +32 -32
- data/test/gir_ffi/builders/unintrospectable_boxed_builder_test.rb +8 -14
- data/test/gir_ffi/builders/unintrospectable_builder_test.rb +23 -23
- data/test/gir_ffi/builders/union_builder_test.rb +12 -15
- data/test/gir_ffi/builders/user_defined_builder_test.rb +147 -147
- data/test/gir_ffi/builders/vfunc_argument_builder_test.rb +40 -40
- data/test/gir_ffi/builders/vfunc_builder_test.rb +145 -157
- data/test/gir_ffi/callback_base_test.rb +9 -9
- data/test/gir_ffi/class_base_test.rb +49 -51
- data/test/gir_ffi/core_test.rb +32 -32
- data/test/gir_ffi/enum_base_test.rb +19 -19
- data/test/gir_ffi/error_type_info_test.rb +23 -23
- data/test/gir_ffi/ffi_ext/pointer_test.rb +5 -5
- data/test/gir_ffi/g_type_test.rb +11 -11
- data/test/gir_ffi/in_pointer_test.rb +70 -50
- data/test/gir_ffi/info_ext/i_callable_info_test.rb +5 -5
- data/test/gir_ffi/info_ext/i_callback_info_test.rb +4 -4
- data/test/gir_ffi/info_ext/i_field_info_test.rb +6 -6
- data/test/gir_ffi/info_ext/i_function_info_test.rb +17 -17
- data/test/gir_ffi/info_ext/i_signal_info_test.rb +8 -8
- data/test/gir_ffi/info_ext/i_type_info_test.rb +229 -215
- data/test/gir_ffi/info_ext/i_unresolved_info_test.rb +4 -4
- data/test/gir_ffi/info_ext/safe_constant_name_test.rb +8 -8
- data/test/gir_ffi/info_ext/safe_function_name_test.rb +8 -8
- data/test/gir_ffi/interface_base_test.rb +8 -8
- data/test/gir_ffi/method_stubber_test.rb +19 -19
- data/test/gir_ffi/object_base_test.rb +19 -19
- data/test/gir_ffi/object_store_test.rb +13 -13
- data/test/gir_ffi/receiver_argument_info_test.rb +15 -15
- data/test/gir_ffi/sized_array_test.rb +68 -68
- data/test/gir_ffi/struct_base_test.rb +8 -8
- data/test/gir_ffi/struct_like_base_test.rb +64 -64
- data/test/gir_ffi/type_map_test.rb +6 -6
- data/test/gir_ffi/unintrospectable_type_info_test.rb +33 -33
- data/test/gir_ffi/union_base_test.rb +8 -8
- data/test/gir_ffi/user_defined_object_info_test.rb +34 -34
- data/test/gir_ffi/user_defined_property_info_test.rb +16 -16
- data/test/gir_ffi/variable_name_generator_test.rb +8 -8
- data/test/gir_ffi/version_test.rb +4 -4
- data/test/gir_ffi/zero_terminated_test.rb +34 -34
- data/test/gir_ffi_test_helper.rb +3 -3
- data/test/integration/callback_exceptions_test.rb +17 -21
- data/test/integration/derived_classes_test.rb +13 -13
- data/test/integration/generated_everything_test.rb +224 -224
- data/test/integration/generated_gimarshallingtests_test.rb +1118 -1017
- data/test/integration/generated_gio_test.rb +36 -36
- data/test/integration/generated_glib_test.rb +4 -6
- data/test/integration/generated_gobject_test.rb +43 -35
- data/test/integration/generated_gst_test.rb +16 -16
- data/test/integration/generated_gtk_source_test.rb +22 -17
- data/test/integration/generated_gtop_test.rb +8 -15
- data/test/integration/generated_pango_ft2_test.rb +2 -2
- data/test/integration/generated_pango_test.rb +4 -4
- data/test/integration/generated_regress_test.rb +1809 -1621
- data/test/integration/generated_secret_test.rb +8 -11
- data/test/integration/generated_utility_test.rb +81 -81
- data/test/integration/generated_warnlib_test.rb +13 -19
- data/test/integration/method_lookup_test.rb +6 -6
- data/test/introspection_test_helper.rb +48 -7
- data/test/minitest/stats_plugin.rb +1 -1
- metadata +11 -28
- data/lib/ffi-glib/array_methods.rb +0 -16
- data/test/gir_ffi/in_out_pointer_test.rb +0 -56
@@ -1,16 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
describe GirFFI::Builders::InitializerBuilder do
|
6
|
-
describe
|
6
|
+
describe "#method_definition" do
|
7
7
|
let(:builder) { GirFFI::Builders::InitializerBuilder.new function_info }
|
8
8
|
let(:code) { builder.method_definition }
|
9
9
|
|
10
|
-
describe
|
11
|
-
let(:function_info) { get_method_introspection_data
|
12
|
-
it
|
13
|
-
code.must_equal
|
10
|
+
describe "for constructors with the default name" do
|
11
|
+
let(:function_info) { get_method_introspection_data "Regress", "TestObj", "new" }
|
12
|
+
it "builds an initializer" do
|
13
|
+
_(code).must_equal <<~CODE
|
14
14
|
def initialize(obj)
|
15
15
|
_v1 = Regress::TestObj.from(obj)
|
16
16
|
_v2 = Regress::Lib.regress_test_obj_new _v1
|
@@ -20,10 +20,10 @@ describe GirFFI::Builders::InitializerBuilder do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
describe
|
24
|
-
let(:function_info) { get_method_introspection_data
|
25
|
-
it
|
26
|
-
code.must_equal
|
23
|
+
describe "for constructors with a custom name" do
|
24
|
+
let(:function_info) { get_method_introspection_data "Regress", "TestObj", "new_from_file" }
|
25
|
+
it "builds a custom initializer" do
|
26
|
+
_(code).must_equal <<~CODE
|
27
27
|
def initialize_from_file(x)
|
28
28
|
_v1 = GirFFI::InPointer.from_utf8(x)
|
29
29
|
_v2 = FFI::MemoryPointer.new(:pointer).write_pointer nil
|
@@ -35,13 +35,13 @@ describe GirFFI::Builders::InitializerBuilder do
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
describe
|
38
|
+
describe "for constructors for boxed types" do
|
39
39
|
let(:function_info) do
|
40
|
-
get_method_introspection_data
|
40
|
+
get_method_introspection_data "GIMarshallingTests", "BoxedStruct", "new"
|
41
41
|
end
|
42
42
|
|
43
|
-
it
|
44
|
-
code.must_equal
|
43
|
+
it "builds an initializer that sets owned to true" do
|
44
|
+
_(code).must_equal <<~CODE
|
45
45
|
def initialize
|
46
46
|
_v1 = GIMarshallingTests::Lib.gi_marshalling_tests_boxed_struct_new
|
47
47
|
store_pointer(_v1)
|
@@ -1,32 +1,32 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
describe GirFFI::Builders::InterfaceBuilder do
|
6
6
|
let(:interface_builder) do
|
7
7
|
GirFFI::Builders::InterfaceBuilder.new(
|
8
|
-
get_introspection_data(
|
8
|
+
get_introspection_data("Regress", "TestInterface"))
|
9
9
|
end
|
10
10
|
|
11
|
-
describe
|
11
|
+
describe "#build_class" do
|
12
12
|
before do
|
13
|
-
info = get_introspection_data
|
13
|
+
info = get_introspection_data "GObject", "TypePlugin"
|
14
14
|
@bldr = GirFFI::Builders::InterfaceBuilder.new info
|
15
15
|
@iface = @bldr.build_class
|
16
16
|
end
|
17
17
|
|
18
|
-
it
|
18
|
+
it "builds an interface as a module" do
|
19
19
|
assert_instance_of Module, @iface
|
20
20
|
end
|
21
21
|
|
22
|
-
it
|
22
|
+
it "creates methods on the interface" do
|
23
23
|
assert_defines_instance_method @iface, :complete_interface_info
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
describe
|
28
|
-
it
|
29
|
-
interface_builder.interface_struct.must_equal Regress::TestInterfaceIface
|
27
|
+
describe "#interface_struct" do
|
28
|
+
it "returns the interface struct type" do
|
29
|
+
_(interface_builder.interface_struct).must_equal Regress::TestInterfaceIface
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -1,39 +1,39 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
describe GirFFI::Builders::ModuleBuilder do
|
6
6
|
let(:gir) { GObjectIntrospection::IRepository.default }
|
7
7
|
|
8
|
-
describe
|
9
|
-
it
|
10
|
-
allow(gir).to receive(:require).with(
|
8
|
+
describe "#find_namespaced_class_info" do
|
9
|
+
it "finds the info in the GIR" do
|
10
|
+
allow(gir).to receive(:require).with("Foo", nil)
|
11
11
|
|
12
|
-
builder = GirFFI::Builders::ModuleBuilder.new
|
12
|
+
builder = GirFFI::Builders::ModuleBuilder.new "Foo"
|
13
13
|
|
14
|
-
expect(gir).to receive(:find_by_name).with(
|
14
|
+
expect(gir).to receive(:find_by_name).with("Foo", "Bar").and_return "gir info"
|
15
15
|
|
16
|
-
builder.find_namespaced_class_info(:Bar).must_equal
|
16
|
+
_(builder.find_namespaced_class_info(:Bar)).must_equal "gir info"
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
20
|
-
allow(gir).to receive(:require).with(
|
19
|
+
it "checks downcased class name as an alternative" do
|
20
|
+
allow(gir).to receive(:require).with("Foo", nil)
|
21
21
|
|
22
|
-
builder = GirFFI::Builders::ModuleBuilder.new
|
22
|
+
builder = GirFFI::Builders::ModuleBuilder.new "Foo"
|
23
23
|
|
24
|
-
expect(gir).to receive(:find_by_name).with(
|
25
|
-
expect(gir).to receive(:find_by_name).with(
|
24
|
+
expect(gir).to receive(:find_by_name).with("Foo", "Bar").and_return nil
|
25
|
+
expect(gir).to receive(:find_by_name).with("Foo", "bar").and_return "gir info"
|
26
26
|
|
27
|
-
builder.find_namespaced_class_info(:Bar).must_equal
|
27
|
+
_(builder.find_namespaced_class_info(:Bar)).must_equal "gir info"
|
28
28
|
end
|
29
29
|
|
30
|
-
it
|
31
|
-
allow(gir).to receive(:require).with(
|
30
|
+
it "raises a clear error if the named class does not exist" do
|
31
|
+
allow(gir).to receive(:require).with("Foo", nil)
|
32
32
|
|
33
|
-
builder = GirFFI::Builders::ModuleBuilder.new
|
33
|
+
builder = GirFFI::Builders::ModuleBuilder.new "Foo"
|
34
34
|
|
35
|
-
expect(gir).to receive(:find_by_name).with(
|
36
|
-
expect(gir).to receive(:find_by_name).with(
|
35
|
+
expect(gir).to receive(:find_by_name).with("Foo", "Bar").and_return nil
|
36
|
+
expect(gir).to receive(:find_by_name).with("Foo", "bar").and_return nil
|
37
37
|
|
38
38
|
assert_raises NameError do
|
39
39
|
builder.find_namespaced_class_info :Bar
|
@@ -1,76 +1,76 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
describe GirFFI::Builders::ObjectBuilder do
|
6
6
|
let(:obj_builder) do
|
7
7
|
GirFFI::Builders::ObjectBuilder.new(
|
8
|
-
get_introspection_data(
|
8
|
+
get_introspection_data("Regress", "TestObj"))
|
9
9
|
end
|
10
10
|
let(:sub_obj_builder) do
|
11
11
|
GirFFI::Builders::ObjectBuilder.new(
|
12
|
-
get_introspection_data(
|
12
|
+
get_introspection_data("Regress", "TestSubObj"))
|
13
13
|
end
|
14
14
|
let(:param_spec_builder) do
|
15
15
|
GirFFI::Builders::ObjectBuilder.new(
|
16
|
-
get_introspection_data(
|
16
|
+
get_introspection_data("GObject", "ParamSpec"))
|
17
17
|
end
|
18
18
|
|
19
|
-
describe
|
19
|
+
describe "#find_signal" do
|
20
20
|
it 'finds the signal "test" for TestObj' do
|
21
|
-
sig = obj_builder.find_signal
|
22
|
-
sig.name.must_equal
|
21
|
+
sig = obj_builder.find_signal "test"
|
22
|
+
_(sig.name).must_equal "test"
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'finds the signal "test" for TestSubObj' do
|
26
|
-
sig = sub_obj_builder.find_signal
|
27
|
-
sig.name.must_equal
|
26
|
+
sig = sub_obj_builder.find_signal "test"
|
27
|
+
_(sig.name).must_equal "test"
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'finds the signal "changed" for Gtk::Entry' do
|
31
|
-
builder = GirFFI::Builders::ObjectBuilder.new get_introspection_data(
|
32
|
-
sig = builder.find_signal
|
33
|
-
sig.name.must_equal
|
31
|
+
builder = GirFFI::Builders::ObjectBuilder.new get_introspection_data("Gtk", "Entry")
|
32
|
+
sig = builder.find_signal "changed"
|
33
|
+
_(sig.name).must_equal "changed"
|
34
34
|
end
|
35
35
|
|
36
36
|
it "returns nil for a signal that doesn't exist" do
|
37
|
-
obj_builder.find_signal(
|
37
|
+
_(obj_builder.find_signal("foo")).must_be_nil
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
describe
|
42
|
-
it
|
43
|
-
prop = obj_builder.find_property(
|
44
|
-
prop.name.must_equal
|
41
|
+
describe "#find_property" do
|
42
|
+
it "finds a property specified on the class itself" do
|
43
|
+
prop = obj_builder.find_property("int")
|
44
|
+
_(prop.name).must_equal "int"
|
45
45
|
end
|
46
46
|
|
47
|
-
it
|
48
|
-
prop = sub_obj_builder.find_property(
|
49
|
-
prop.name.must_equal
|
47
|
+
it "finds a property specified on the parent class" do
|
48
|
+
prop = sub_obj_builder.find_property("int")
|
49
|
+
_(prop.name).must_equal "int"
|
50
50
|
end
|
51
51
|
|
52
|
-
it
|
53
|
-
sub_obj_builder.find_property(
|
52
|
+
it "returns nil if the property is not found" do
|
53
|
+
_(sub_obj_builder.find_property("this-property-does-not-exist")).must_be_nil
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
describe
|
58
|
-
it
|
59
|
-
obj_builder.object_class_struct.must_equal Regress::TestObjClass
|
57
|
+
describe "#object_class_struct" do
|
58
|
+
it "returns the class struct type" do
|
59
|
+
_(obj_builder.object_class_struct).must_equal Regress::TestObjClass
|
60
60
|
end
|
61
61
|
|
62
|
-
it
|
63
|
-
binding_info = get_introspection_data
|
62
|
+
it "returns the parent struct type for classes without their own struct" do
|
63
|
+
binding_info = get_introspection_data "GObject", "Binding"
|
64
64
|
builder = GirFFI::Builders::ObjectBuilder.new binding_info
|
65
|
-
builder.object_class_struct.must_equal GObject::ObjectClass
|
65
|
+
_(builder.object_class_struct).must_equal GObject::ObjectClass
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
describe
|
70
|
-
let(:info) { get_introspection_data
|
69
|
+
describe "for a struct without defined fields" do
|
70
|
+
let(:info) { get_introspection_data "GObject", "Binding" }
|
71
71
|
|
72
|
-
it
|
73
|
-
info.n_fields.must_equal 0
|
72
|
+
it "uses a single field of the parent struct type as the default layout" do
|
73
|
+
_(info.n_fields).must_equal 0
|
74
74
|
|
75
75
|
builder = GirFFI::Builders::ObjectBuilder.new info
|
76
76
|
|
@@ -79,20 +79,20 @@ describe GirFFI::Builders::ObjectBuilder do
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
describe
|
82
|
+
describe "#eligible_properties" do
|
83
83
|
let(:wi_builder) do
|
84
84
|
GirFFI::Builders::ObjectBuilder.new(
|
85
|
-
get_introspection_data(
|
85
|
+
get_introspection_data("Regress", "TestWi8021x"))
|
86
86
|
end
|
87
87
|
|
88
|
-
it
|
88
|
+
it "includes properties that do not have a matching getter method" do
|
89
89
|
result = obj_builder.eligible_properties
|
90
|
-
result.map(&:name).must_include
|
90
|
+
_(result.map(&:name)).must_include "double"
|
91
91
|
end
|
92
92
|
|
93
|
-
it
|
93
|
+
it "skips properties that have a matching getter method" do
|
94
94
|
result = wi_builder.eligible_properties
|
95
|
-
result.map(&:name).wont_include
|
95
|
+
_(result.map(&:name)).wont_include "testbool"
|
96
96
|
end
|
97
97
|
end
|
98
98
|
end
|
@@ -1,161 +1,158 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi_test_helper"
|
4
4
|
|
5
5
|
describe GirFFI::Builders::PropertyBuilder do
|
6
6
|
let(:builder) { GirFFI::Builders::PropertyBuilder.new property_info }
|
7
7
|
|
8
|
-
describe
|
9
|
-
let(:property_info) { get_property_introspection_data(
|
10
|
-
it
|
11
|
-
expected =
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
8
|
+
describe "for a property of type :glist" do
|
9
|
+
let(:property_info) { get_property_introspection_data("Regress", "TestObj", "list") }
|
10
|
+
it "generates the correct getter definition" do
|
11
|
+
expected = <<~CODE
|
12
|
+
def list
|
13
|
+
_v1 = get_property('list')
|
14
|
+
_v2 = GLib::List.wrap(:utf8, _v1)
|
15
|
+
_v2
|
16
|
+
end
|
17
17
|
CODE
|
18
18
|
|
19
|
-
builder.getter_def.must_equal expected
|
19
|
+
_(builder.getter_def).must_equal expected
|
20
20
|
end
|
21
21
|
|
22
|
-
it
|
23
|
-
expected =
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
22
|
+
it "generates the correct setter definition" do
|
23
|
+
expected = <<~CODE
|
24
|
+
def list= value
|
25
|
+
_v1 = GLib::List.from(:utf8, value)
|
26
|
+
set_property("list", _v1)
|
27
|
+
end
|
28
28
|
CODE
|
29
29
|
|
30
|
-
builder.setter_def.must_equal expected
|
30
|
+
_(builder.setter_def).must_equal expected
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
describe
|
35
|
-
let(:property_info) { get_property_introspection_data(
|
36
|
-
it
|
37
|
-
expected =
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
34
|
+
describe "for a property of type :ghash" do
|
35
|
+
let(:property_info) { get_property_introspection_data("Regress", "TestObj", "hash-table") }
|
36
|
+
it "generates the correct getter definition" do
|
37
|
+
expected = <<~CODE
|
38
|
+
def hash_table
|
39
|
+
_v1 = get_property('hash-table')
|
40
|
+
_v2 = GLib::HashTable.wrap([:utf8, :gint8], _v1)
|
41
|
+
_v2
|
42
|
+
end
|
43
43
|
CODE
|
44
44
|
|
45
|
-
builder.getter_def.must_equal expected
|
45
|
+
_(builder.getter_def).must_equal expected
|
46
46
|
end
|
47
47
|
|
48
|
-
it
|
49
|
-
expected =
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
48
|
+
it "generates the correct setter definition" do
|
49
|
+
expected = <<~CODE
|
50
|
+
def hash_table= value
|
51
|
+
_v1 = GLib::HashTable.from([:utf8, :gint8], value)
|
52
|
+
set_property("hash-table", _v1)
|
53
|
+
end
|
54
54
|
CODE
|
55
55
|
|
56
|
-
builder.setter_def.must_equal expected
|
56
|
+
_(builder.setter_def).must_equal expected
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
describe
|
60
|
+
describe "for a property of type :strv" do
|
61
61
|
let(:property_info) do
|
62
|
-
get_property_introspection_data(
|
63
|
-
|
64
|
-
|
65
|
-
end
|
66
|
-
before do
|
67
|
-
skip unless property_info
|
62
|
+
get_property_introspection_data("GIMarshallingTests",
|
63
|
+
"PropertiesObject",
|
64
|
+
"some-strv")
|
68
65
|
end
|
69
66
|
|
70
|
-
it
|
71
|
-
expected =
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
67
|
+
it "generates the correct getter definition" do
|
68
|
+
expected = <<~CODE
|
69
|
+
def some_strv
|
70
|
+
_v1 = get_property('some-strv')
|
71
|
+
_v1
|
72
|
+
end
|
76
73
|
CODE
|
77
74
|
|
78
|
-
builder.getter_def.must_equal expected
|
75
|
+
_(builder.getter_def).must_equal expected
|
79
76
|
end
|
80
77
|
|
81
|
-
it
|
82
|
-
expected =
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
78
|
+
it "generates the correct setter definition" do
|
79
|
+
expected = <<~CODE
|
80
|
+
def some_strv= value
|
81
|
+
_v1 = GLib::Strv.from(value)
|
82
|
+
set_property("some-strv", _v1)
|
83
|
+
end
|
87
84
|
CODE
|
88
85
|
|
89
|
-
builder.setter_def.must_equal expected
|
86
|
+
_(builder.setter_def).must_equal expected
|
90
87
|
end
|
91
88
|
end
|
92
89
|
|
93
|
-
describe
|
94
|
-
let(:property_info) { get_property_introspection_data(
|
95
|
-
it
|
96
|
-
expected =
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
90
|
+
describe "for a property of type :utf8" do
|
91
|
+
let(:property_info) { get_property_introspection_data("Regress", "TestObj", "string") }
|
92
|
+
it "generates the correct getter definition" do
|
93
|
+
expected = <<~CODE
|
94
|
+
def string
|
95
|
+
_v1 = get_property('string')
|
96
|
+
_v1
|
97
|
+
end
|
101
98
|
CODE
|
102
99
|
|
103
|
-
builder.getter_def.must_equal expected
|
100
|
+
_(builder.getter_def).must_equal expected
|
104
101
|
end
|
105
102
|
|
106
|
-
it
|
107
|
-
expected =
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
103
|
+
it "generates the correct setter definition" do
|
104
|
+
expected = <<~CODE
|
105
|
+
def string= value
|
106
|
+
_v1 = value
|
107
|
+
set_property("string", _v1)
|
108
|
+
end
|
112
109
|
CODE
|
113
110
|
|
114
|
-
builder.setter_def.must_equal expected
|
111
|
+
_(builder.setter_def).must_equal expected
|
115
112
|
end
|
116
113
|
end
|
117
114
|
|
118
|
-
describe
|
115
|
+
describe "for a property of a callback type" do
|
119
116
|
let(:property_info) do
|
120
|
-
get_property_introspection_data(
|
117
|
+
get_property_introspection_data("Regress", "AnnotationObject", "function-property")
|
121
118
|
end
|
122
119
|
|
123
|
-
it
|
124
|
-
expected =
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
120
|
+
it "generates the correct getter definition" do
|
121
|
+
expected = <<~CODE
|
122
|
+
def function_property
|
123
|
+
_v1 = get_property('function-property')
|
124
|
+
_v2 = Regress::AnnotationCallback.wrap(_v1)
|
125
|
+
_v2
|
126
|
+
end
|
130
127
|
CODE
|
131
128
|
|
132
|
-
builder.getter_def.must_equal expected
|
129
|
+
_(builder.getter_def).must_equal expected
|
133
130
|
end
|
134
131
|
|
135
|
-
it
|
136
|
-
expected =
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
132
|
+
it "generates the correct setter definition" do
|
133
|
+
expected = <<~CODE
|
134
|
+
def function_property= value
|
135
|
+
_v1 = Regress::AnnotationCallback.from(value)
|
136
|
+
set_property("function-property", _v1)
|
137
|
+
end
|
141
138
|
CODE
|
142
139
|
|
143
|
-
builder.setter_def.must_equal expected
|
140
|
+
_(builder.setter_def).must_equal expected
|
144
141
|
end
|
145
142
|
end
|
146
143
|
|
147
|
-
describe
|
144
|
+
describe "#container_defines_getter_method?" do
|
148
145
|
let(:property_info) { Object.new.tap { |o| o.extend GirFFI::InfoExt::IPropertyInfo } }
|
149
146
|
let(:container_info) { Object.new }
|
150
147
|
|
151
148
|
before do
|
152
149
|
allow(property_info).to receive(:container).and_return container_info
|
153
|
-
allow(property_info).to receive(:name).and_return
|
154
|
-
allow(container_info).to receive(:find_instance_method).with(
|
150
|
+
allow(property_info).to receive(:name).and_return "foo-bar"
|
151
|
+
allow(container_info).to receive(:find_instance_method).with("foo_bar").and_return true
|
155
152
|
end
|
156
153
|
|
157
|
-
it
|
158
|
-
builder.container_defines_getter_method
|
154
|
+
it "finds methods with underscores for properties with dashes" do
|
155
|
+
_(builder.container_defines_getter_method?).must_equal true
|
159
156
|
end
|
160
157
|
end
|
161
158
|
end
|