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,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "ffi-gobject/closure"
|
4
4
|
|
5
5
|
module GObject
|
6
6
|
# Encapsulates Ruby blocks as GObject Closures.
|
@@ -36,7 +36,7 @@ module GObject
|
|
36
36
|
|
37
37
|
result = rclosure.invoke_block(*args)
|
38
38
|
|
39
|
-
return_value
|
39
|
+
return_value&.set_value(result)
|
40
40
|
end
|
41
41
|
|
42
42
|
# @api private
|
data/lib/ffi-gobject/value.rb
CHANGED
@@ -29,29 +29,29 @@ module GObject
|
|
29
29
|
end
|
30
30
|
|
31
31
|
METHOD_MAP = {
|
32
|
-
TYPE_INVALID => [:get_none,
|
32
|
+
TYPE_INVALID => [:get_none, :set_none],
|
33
33
|
# TYPE_NONE is skipped
|
34
|
-
TYPE_INTERFACE => [:get_object,
|
35
|
-
TYPE_CHAR => [:get_schar,
|
36
|
-
TYPE_UCHAR => [:get_uchar,
|
37
|
-
TYPE_BOOLEAN => [:get_boolean,
|
38
|
-
TYPE_INT => [:get_int,
|
39
|
-
TYPE_UINT => [:get_uint,
|
40
|
-
TYPE_LONG => [:get_long,
|
41
|
-
TYPE_ULONG => [:get_ulong,
|
42
|
-
TYPE_INT64 => [:get_int64,
|
43
|
-
TYPE_UINT64 => [:get_uint64,
|
44
|
-
TYPE_ENUM => [:get_enum_enhanced,
|
45
|
-
TYPE_FLAGS => [:
|
46
|
-
TYPE_FLOAT => [:get_float,
|
47
|
-
TYPE_DOUBLE => [:get_double,
|
48
|
-
TYPE_STRING => [:get_string,
|
49
|
-
TYPE_POINTER => [:get_pointer,
|
50
|
-
TYPE_BOXED => [:get_boxed,
|
51
|
-
TYPE_PARAM => [:get_param,
|
52
|
-
TYPE_OBJECT => [:get_object,
|
53
|
-
TYPE_GTYPE => [:get_gtype,
|
54
|
-
TYPE_VARIANT => [:get_variant,
|
34
|
+
TYPE_INTERFACE => [:get_object, :set_instance_enhanced],
|
35
|
+
TYPE_CHAR => [:get_schar, :set_schar],
|
36
|
+
TYPE_UCHAR => [:get_uchar, :set_uchar],
|
37
|
+
TYPE_BOOLEAN => [:get_boolean, :set_boolean],
|
38
|
+
TYPE_INT => [:get_int, :set_int],
|
39
|
+
TYPE_UINT => [:get_uint, :set_uint],
|
40
|
+
TYPE_LONG => [:get_long, :set_long],
|
41
|
+
TYPE_ULONG => [:get_ulong, :set_ulong],
|
42
|
+
TYPE_INT64 => [:get_int64, :set_int64],
|
43
|
+
TYPE_UINT64 => [:get_uint64, :set_uint64],
|
44
|
+
TYPE_ENUM => [:get_enum_enhanced, :set_enum_enhanced],
|
45
|
+
TYPE_FLAGS => [:get_flags_enhanced, :set_flags_enhanced],
|
46
|
+
TYPE_FLOAT => [:get_float, :set_float],
|
47
|
+
TYPE_DOUBLE => [:get_double, :set_double],
|
48
|
+
TYPE_STRING => [:get_string, :set_string],
|
49
|
+
TYPE_POINTER => [:get_pointer, :set_pointer],
|
50
|
+
TYPE_BOXED => [:get_boxed, :set_boxed],
|
51
|
+
TYPE_PARAM => [:get_param, :set_param],
|
52
|
+
TYPE_OBJECT => [:get_object, :set_instance_enhanced],
|
53
|
+
TYPE_GTYPE => [:get_gtype, :set_gtype],
|
54
|
+
TYPE_VARIANT => [:get_variant, :set_variant]
|
55
55
|
}.freeze
|
56
56
|
|
57
57
|
def set_value(val)
|
@@ -131,11 +131,11 @@ module GObject
|
|
131
131
|
end
|
132
132
|
|
133
133
|
CLASS_TO_GTYPE_MAP = {
|
134
|
-
NilClass
|
135
|
-
TrueClass
|
134
|
+
NilClass => TYPE_INVALID,
|
135
|
+
TrueClass => TYPE_BOOLEAN,
|
136
136
|
FalseClass => TYPE_BOOLEAN,
|
137
|
-
Integer
|
138
|
-
String
|
137
|
+
Integer => TYPE_INT,
|
138
|
+
String => TYPE_STRING
|
139
139
|
}.freeze
|
140
140
|
|
141
141
|
def init_for_ruby_value(val)
|
@@ -157,7 +157,7 @@ module GObject
|
|
157
157
|
end
|
158
158
|
|
159
159
|
def set_enum_enhanced(val)
|
160
|
-
val = current_gtype_class
|
160
|
+
val = current_gtype_class.to_native(val, nil)
|
161
161
|
set_enum val
|
162
162
|
end
|
163
163
|
|
@@ -165,6 +165,15 @@ module GObject
|
|
165
165
|
current_gtype_class.wrap(get_enum)
|
166
166
|
end
|
167
167
|
|
168
|
+
def set_flags_enhanced(val)
|
169
|
+
val = current_gtype_class.to_native(val, nil)
|
170
|
+
set_flags val
|
171
|
+
end
|
172
|
+
|
173
|
+
def get_flags_enhanced
|
174
|
+
current_gtype_class.wrap(get_flags)
|
175
|
+
end
|
176
|
+
|
168
177
|
def current_gtype_class
|
169
178
|
GirFFI::Builder.build_by_gtype(current_gtype)
|
170
179
|
end
|
@@ -198,7 +207,7 @@ module GObject
|
|
198
207
|
|
199
208
|
def method_map_entry
|
200
209
|
METHOD_MAP[current_gtype] || METHOD_MAP[current_fundamental_type] ||
|
201
|
-
raise("No method map entry for #{current_gtype_name}")
|
210
|
+
raise("No method map entry for '#{current_gtype_name}'")
|
202
211
|
end
|
203
212
|
end
|
204
213
|
end
|
data/lib/ffi-gobject.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi/core"
|
4
4
|
|
5
5
|
# Bypass check for existing modules
|
6
|
-
GirFFI::Builders::ModuleBuilder.new(
|
6
|
+
GirFFI::Builders::ModuleBuilder.new("GObject").generate
|
7
7
|
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
8
|
+
require "ffi-gobject/value"
|
9
|
+
require "ffi-gobject/initially_unowned"
|
10
|
+
require "ffi-gobject/closure"
|
11
|
+
require "ffi-gobject/object"
|
12
|
+
require "ffi-gobject/object_class"
|
13
|
+
require "ffi-gobject/param_spec"
|
14
|
+
require "ffi-gobject/ruby_closure"
|
15
|
+
require "gir_ffi/signal_not_found_error"
|
16
16
|
|
17
17
|
# Module representing GLib's GObject namespace.
|
18
18
|
module GObject
|
@@ -47,7 +47,7 @@ module GObject
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def self.signal_emit(object, detailed_signal, *args)
|
50
|
-
signal, detail = detailed_signal.split(
|
50
|
+
signal, detail = detailed_signal.split("::")
|
51
51
|
signal_id = signal_lookup_from_instance signal, object
|
52
52
|
detail_quark = GLib.quark_from_string(detail)
|
53
53
|
|
@@ -63,9 +63,9 @@ module GObject
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def self.signal_connect(object, detailed_signal, data = nil, after = false, &block)
|
66
|
-
raise ArgumentError,
|
66
|
+
raise ArgumentError, "Block needed" unless block_given?
|
67
67
|
|
68
|
-
signal_name, = detailed_signal.split(
|
68
|
+
signal_name, = detailed_signal.split("::")
|
69
69
|
sig_info = object.class.find_signal signal_name
|
70
70
|
|
71
71
|
closure = sig_info.wrap_in_closure do |*args|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "ffi"
|
4
4
|
|
5
5
|
module GObjectIntrospection
|
6
6
|
# Provides access to the g_type_init function.
|
@@ -12,7 +12,7 @@ module GObjectIntrospection
|
|
12
12
|
# Module for attaching g_type_init from the gobject library.
|
13
13
|
module Lib
|
14
14
|
extend FFI::Library
|
15
|
-
ffi_lib
|
15
|
+
ffi_lib "gobject-2.0"
|
16
16
|
attach_function :g_type_init, [], :void
|
17
17
|
end
|
18
18
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "ffi-gobject_introspection/i_base_info"
|
4
4
|
module GObjectIntrospection
|
5
5
|
# Wraps a GIArgInfo struct.
|
6
6
|
# Represents an argument.
|
@@ -46,7 +46,7 @@ module GObjectIntrospection
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def argument_type
|
49
|
-
ITypeInfo.wrap Lib.g_arg_info_get_type(self)
|
49
|
+
@argument_type ||= ITypeInfo.wrap Lib.g_arg_info_get_type(self)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -5,7 +5,7 @@ module GObjectIntrospection
|
|
5
5
|
# Decendant types will be implemented as needed.
|
6
6
|
class IBaseInfo
|
7
7
|
def initialize(ptr, lib = Lib)
|
8
|
-
raise ArgumentError,
|
8
|
+
raise ArgumentError, "ptr must not be null" if ptr.null?
|
9
9
|
|
10
10
|
ObjectSpace.define_finalizer self, self.class.make_finalizer(lib, ptr)
|
11
11
|
|
@@ -40,13 +40,15 @@ module GObjectIntrospection
|
|
40
40
|
#
|
41
41
|
def self.build_array_method(method, single = nil)
|
42
42
|
method = method.to_s
|
43
|
+
cache_ivar = "@#{method}_cache"
|
43
44
|
single ||= method[0..-2]
|
44
45
|
count = method.sub(/^(get_)?/, '\\1n_')
|
45
46
|
class_eval <<-CODE, __FILE__, __LINE__ + 1
|
46
47
|
def #{method}
|
47
|
-
|
48
|
-
#{
|
49
|
-
|
48
|
+
#{cache_ivar} ||=
|
49
|
+
(0..(#{count} - 1)).map do |i|
|
50
|
+
#{single} i
|
51
|
+
end
|
50
52
|
end
|
51
53
|
CODE
|
52
54
|
end
|
@@ -69,41 +71,49 @@ module GObjectIntrospection
|
|
69
71
|
#
|
70
72
|
def self.build_finder_method(method, counter = nil, fetcher = nil)
|
71
73
|
method = method.to_s
|
72
|
-
|
74
|
+
cache_ivar = "@#{method}_cache"
|
75
|
+
single = method.sub(/^find_/, "")
|
73
76
|
counter ||= "n_#{single}s"
|
74
77
|
fetcher ||= single
|
75
78
|
class_eval <<-CODE, __FILE__, __LINE__ + 1
|
76
79
|
def #{method}(name)
|
80
|
+
#{cache_ivar} ||= begin
|
81
|
+
hash = {}
|
82
|
+
#{counter}.times do |i|
|
83
|
+
it = #{fetcher}(i)
|
84
|
+
hash[it.name] = it
|
85
|
+
end
|
86
|
+
hash
|
87
|
+
end
|
77
88
|
name = name.to_s
|
78
|
-
#{
|
79
|
-
it = #{fetcher}(i)
|
80
|
-
return it if it.name == name
|
81
|
-
end
|
82
|
-
nil
|
89
|
+
#{cache_ivar}[name]
|
83
90
|
end
|
84
91
|
CODE
|
85
92
|
end
|
86
93
|
|
87
94
|
def name
|
88
|
-
Lib.g_base_info_get_name self
|
95
|
+
@name ||= Lib.g_base_info_get_name self
|
89
96
|
end
|
90
97
|
|
91
98
|
def info_type
|
92
|
-
Lib.g_base_info_get_type self
|
99
|
+
@info_type ||= Lib.g_base_info_get_type self
|
93
100
|
end
|
94
101
|
|
95
102
|
def namespace
|
96
|
-
Lib.g_base_info_get_namespace self
|
103
|
+
@namespace ||= Lib.g_base_info_get_namespace self
|
97
104
|
end
|
98
105
|
|
99
106
|
def safe_namespace
|
100
|
-
namespace.
|
107
|
+
namespace.sub(/^[a-z]/, &:upcase)
|
101
108
|
end
|
102
109
|
|
110
|
+
# TODO: Avoid calling for IStructInfo
|
103
111
|
def container
|
104
|
-
|
105
|
-
|
106
|
-
|
112
|
+
@container ||= begin
|
113
|
+
ptr = Lib.g_base_info_get_container self
|
114
|
+
Lib.g_base_info_ref ptr
|
115
|
+
IRepository.wrap_ibaseinfo_pointer ptr
|
116
|
+
end
|
107
117
|
end
|
108
118
|
|
109
119
|
def deprecated?
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "ffi-gobject_introspection/i_base_info"
|
4
|
+
require "ffi-gobject_introspection/i_type_info"
|
5
|
+
require "ffi-gobject_introspection/i_arg_info"
|
6
6
|
|
7
7
|
module GObjectIntrospection
|
8
8
|
# Wraps a GICallableInfo struct; represents a callable, either
|
9
9
|
# IFunctionInfo, ICallbackInfo or IVFuncInfo.
|
10
10
|
class ICallableInfo < IBaseInfo
|
11
11
|
def return_type
|
12
|
-
ITypeInfo.wrap Lib.g_callable_info_get_return_type(self)
|
12
|
+
@return_type ||= ITypeInfo.wrap Lib.g_callable_info_get_return_type(self)
|
13
13
|
end
|
14
14
|
|
15
15
|
def caller_owns
|
@@ -20,7 +20,7 @@ module GObjectIntrospection
|
|
20
20
|
def value
|
21
21
|
case type_tag
|
22
22
|
when :utf8
|
23
|
-
raw_value.force_encoding(
|
23
|
+
raw_value.force_encoding("utf-8")
|
24
24
|
when :gboolean
|
25
25
|
raw_value.nonzero? ? true : false
|
26
26
|
else
|
@@ -29,7 +29,7 @@ module GObjectIntrospection
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def constant_type
|
32
|
-
ITypeInfo.wrap Lib.g_constant_info_get_type self
|
32
|
+
@constant_type ||= ITypeInfo.wrap Lib.g_constant_info_get_type self
|
33
33
|
end
|
34
34
|
|
35
35
|
private
|
@@ -21,7 +21,7 @@ module GObjectIntrospection
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def parent
|
24
|
-
IObjectInfo.wrap Lib.g_object_info_get_parent(self)
|
24
|
+
@parent ||= IObjectInfo.wrap Lib.g_object_info_get_parent(self)
|
25
25
|
end
|
26
26
|
|
27
27
|
def n_interfaces
|
@@ -59,7 +59,7 @@ module GObjectIntrospection
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def find_property(name)
|
62
|
-
name = name.to_s.tr(
|
62
|
+
name = name.to_s.tr("_", "-")
|
63
63
|
properties.find { |prop| prop.name == name }
|
64
64
|
end
|
65
65
|
|
@@ -5,11 +5,11 @@ module GObjectIntrospection
|
|
5
5
|
# Represents a property of an IObjectInfo or an IInterfaceInfo.
|
6
6
|
class IPropertyInfo < IBaseInfo
|
7
7
|
def property_type
|
8
|
-
ITypeInfo.wrap Lib.g_property_info_get_type(self)
|
8
|
+
@property_type ||= ITypeInfo.wrap Lib.g_property_info_get_type(self)
|
9
9
|
end
|
10
10
|
|
11
11
|
def flags
|
12
|
-
Lib.g_property_info_get_flags self
|
12
|
+
@flags ||= Lib.g_property_info_get_flags self
|
13
13
|
end
|
14
14
|
|
15
15
|
def readable?
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "singleton"
|
4
4
|
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
5
|
+
require "ffi-gobject_introspection/lib"
|
6
|
+
require "ffi-gobject_introspection/strv"
|
7
|
+
require "ffi-gobject_introspection/g_error"
|
8
8
|
|
9
9
|
module GObjectIntrospection
|
10
10
|
# The Gobject Introspection Repository. This class is the point of
|
@@ -58,13 +58,16 @@ module GObjectIntrospection
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def find_by_name(namespace, name)
|
61
|
-
|
61
|
+
@name_cache ||= {}
|
62
|
+
@name_cache[[namespace, name]] ||=
|
63
|
+
wrap_info Lib.g_irepository_find_by_name(self, namespace, name)
|
62
64
|
end
|
63
65
|
|
64
66
|
def find_by_gtype(gtype)
|
65
67
|
raise ArgumentError, "Type #{gtype} is not a valid type" if gtype == 0
|
66
68
|
|
67
|
-
|
69
|
+
@gtype_cache ||= {}
|
70
|
+
@gtype_cache[gtype] ||= wrap_info Lib.g_irepository_find_by_gtype(self, gtype)
|
68
71
|
end
|
69
72
|
|
70
73
|
def dependencies(namespace)
|