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
data/lib/gir_ffi/enum_base.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi/error_type_info"
|
4
4
|
|
5
5
|
module GirFFI
|
6
6
|
# Represents an error argument with the same interface as IArgInfo
|
@@ -14,7 +14,7 @@ module GirFFI
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def name
|
17
|
-
|
17
|
+
"_error"
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
data/lib/gir_ffi/ffi_ext.rb
CHANGED
data/lib/gir_ffi/flags_base.rb
CHANGED
data/lib/gir_ffi/in_pointer.rb
CHANGED
@@ -29,6 +29,8 @@ module GirFFI
|
|
29
29
|
case type
|
30
30
|
when :utf8, :filename
|
31
31
|
from_utf8 val
|
32
|
+
when :gfloat, :gdouble, :gint64, :guint64
|
33
|
+
from_basic_type type, val
|
32
34
|
when :gint32, :guint32, :gint8, :GType
|
33
35
|
FFI::Pointer.new val
|
34
36
|
when GirFFI::EnumLikeBase
|
@@ -51,6 +53,14 @@ module GirFFI
|
|
51
53
|
class << self
|
52
54
|
private
|
53
55
|
|
56
|
+
def from_basic_type(type, value)
|
57
|
+
ffi_type = TypeMap.type_specification_to_ffi_type type
|
58
|
+
FFI::MemoryPointer.new(ffi_type).tap do |block|
|
59
|
+
block.autorelease = false
|
60
|
+
block.send "put_#{ffi_type}", 0, value
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
54
64
|
def from_simple_type_array(type, ary)
|
55
65
|
case type
|
56
66
|
when :utf8, :filename
|
@@ -13,6 +13,6 @@ module GirFFI
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
GObjectIntrospection::ICallbackInfo.
|
17
|
-
GObjectIntrospection::IConstantInfo.
|
18
|
-
GObjectIntrospection::IRegisteredTypeInfo.
|
16
|
+
GObjectIntrospection::ICallbackInfo.include GirFFI::InfoExt::FullTypeName
|
17
|
+
GObjectIntrospection::IConstantInfo.include GirFFI::InfoExt::FullTypeName
|
18
|
+
GObjectIntrospection::IRegisteredTypeInfo.include GirFFI::InfoExt::FullTypeName
|
@@ -5,7 +5,7 @@ module GirFFI
|
|
5
5
|
# Extensions for GObjectIntrospection::IPropertyInfo needed by GirFFI
|
6
6
|
module IPropertyInfo
|
7
7
|
def getter_name
|
8
|
-
name.tr(
|
8
|
+
name.tr("-", "_")
|
9
9
|
end
|
10
10
|
|
11
11
|
def setter_name
|
@@ -15,4 +15,4 @@ module GirFFI
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
GObjectIntrospection::IPropertyInfo.
|
18
|
+
GObjectIntrospection::IPropertyInfo.include GirFFI::InfoExt::IPropertyInfo
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi/builder_helper"
|
4
4
|
|
5
5
|
module GirFFI
|
6
6
|
module InfoExt
|
@@ -20,15 +20,14 @@ module GirFFI
|
|
20
20
|
|
21
21
|
def find_instance_method(method)
|
22
22
|
info = find_method method
|
23
|
-
return info if info
|
23
|
+
return info if info&.method?
|
24
24
|
end
|
25
25
|
|
26
26
|
def find_method(_method)
|
27
|
-
raise
|
27
|
+
raise "Must be overridden in subclass"
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
GObjectIntrospection::IRegisteredTypeInfo.
|
34
|
-
GirFFI::InfoExt::IRegisteredTypeInfo
|
33
|
+
GObjectIntrospection::IRegisteredTypeInfo.include GirFFI::InfoExt::IRegisteredTypeInfo
|
@@ -17,8 +17,8 @@ module GirFFI
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def arguments_to_gvalues(instance, arguments)
|
20
|
-
arg_g_values =
|
21
|
-
|
20
|
+
arg_g_values = argument_types.zip(arguments).map do |type, arg|
|
21
|
+
type.make_g_value.tap { |it| it.set_value arg }
|
22
22
|
end
|
23
23
|
|
24
24
|
arg_g_values.unshift GObject::Value.wrap_instance(instance)
|
@@ -27,8 +27,12 @@ module GirFFI
|
|
27
27
|
def gvalue_for_return_value
|
28
28
|
return_type.make_g_value
|
29
29
|
end
|
30
|
+
|
31
|
+
def argument_types
|
32
|
+
@argument_types ||= args.map(&:argument_type)
|
33
|
+
end
|
30
34
|
end
|
31
35
|
end
|
32
36
|
end
|
33
37
|
|
34
|
-
GObjectIntrospection::ISignalInfo.
|
38
|
+
GObjectIntrospection::ISignalInfo.include GirFFI::InfoExt::ISignalInfo
|
@@ -1,13 +1,34 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi/builder_helper"
|
4
4
|
|
5
5
|
module GirFFI
|
6
6
|
module InfoExt
|
7
7
|
# Extensions for GObjectIntrospection::ITypeInfo needed by GirFFI
|
8
8
|
module ITypeInfo
|
9
|
+
FLATTENED_TAG_TO_GTYPE_MAP = {
|
10
|
+
gboolean: GObject::TYPE_BOOLEAN,
|
11
|
+
gint32: GObject::TYPE_INT,
|
12
|
+
gint64: GObject::TYPE_INT64,
|
13
|
+
guint64: GObject::TYPE_UINT64,
|
14
|
+
void: GObject::TYPE_NONE
|
15
|
+
}.freeze
|
16
|
+
|
17
|
+
FLATTENED_TAG_POINTER_TO_GTYPE_MAP = {
|
18
|
+
array: GObject::TYPE_ARRAY,
|
19
|
+
ghash: GObject::TYPE_HASH_TABLE,
|
20
|
+
strv: GObject::TYPE_STRV,
|
21
|
+
utf8: GObject::TYPE_STRING
|
22
|
+
}.freeze
|
23
|
+
|
9
24
|
def gtype
|
10
|
-
|
25
|
+
return interface.gtype if tag == :interface
|
26
|
+
|
27
|
+
if pointer?
|
28
|
+
FLATTENED_TAG_POINTER_TO_GTYPE_MAP.fetch(flattened_tag, GObject::TYPE_POINTER)
|
29
|
+
else
|
30
|
+
FLATTENED_TAG_TO_GTYPE_MAP.fetch(flattened_tag)
|
31
|
+
end
|
11
32
|
end
|
12
33
|
|
13
34
|
def make_g_value
|
@@ -24,14 +45,15 @@ module GirFFI
|
|
24
45
|
end
|
25
46
|
|
26
47
|
def flattened_tag
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
48
|
+
@flattened_tag ||=
|
49
|
+
case tag
|
50
|
+
when :interface
|
51
|
+
interface_type
|
52
|
+
when :array
|
53
|
+
flattened_array_type
|
54
|
+
else
|
55
|
+
tag
|
56
|
+
end
|
35
57
|
end
|
36
58
|
|
37
59
|
def interface_type
|
@@ -59,22 +81,22 @@ module GirFFI
|
|
59
81
|
end
|
60
82
|
|
61
83
|
def interface_class
|
62
|
-
Builder.build_class interface if tag == :interface
|
84
|
+
@interface_class ||= Builder.build_class interface if tag == :interface
|
63
85
|
end
|
64
86
|
|
65
87
|
TAG_TO_WRAPPER_CLASS_MAP = {
|
66
|
-
array:
|
67
|
-
byte_array:
|
68
|
-
c:
|
69
|
-
error:
|
70
|
-
ghash:
|
71
|
-
glist:
|
72
|
-
gslist:
|
73
|
-
ptr_array:
|
74
|
-
strv:
|
75
|
-
utf8:
|
76
|
-
void:
|
77
|
-
zero_terminated:
|
88
|
+
array: "GLib::Array",
|
89
|
+
byte_array: "GLib::ByteArray",
|
90
|
+
c: "GirFFI::SizedArray",
|
91
|
+
error: "GLib::Error",
|
92
|
+
ghash: "GLib::HashTable",
|
93
|
+
glist: "GLib::List",
|
94
|
+
gslist: "GLib::SList",
|
95
|
+
ptr_array: "GLib::PtrArray",
|
96
|
+
strv: "GLib::Strv",
|
97
|
+
utf8: "GirFFI::InPointer", # TODO: Create a string-like class
|
98
|
+
void: "GirFFI::InPointer", # TODO: Create a void-pointer class
|
99
|
+
zero_terminated: "GirFFI::ZeroTerminated"
|
78
100
|
}.freeze
|
79
101
|
|
80
102
|
# TODO: Use class rather than class name
|
@@ -144,7 +166,7 @@ module GirFFI
|
|
144
166
|
end
|
145
167
|
|
146
168
|
def needs_c_to_ruby_conversion_for_closures?
|
147
|
-
[:array, :c, :ghash, :glist, :struct, :strv].include?(flattened_tag)
|
169
|
+
[:array, :c, :error, :ghash, :glist, :struct, :strv].include?(flattened_tag)
|
148
170
|
end
|
149
171
|
|
150
172
|
def needs_ruby_to_c_conversion_for_closures?
|
@@ -170,7 +192,7 @@ module GirFFI
|
|
170
192
|
end
|
171
193
|
end
|
172
194
|
|
173
|
-
GOBJECT_VALUE_NAME =
|
195
|
+
GOBJECT_VALUE_NAME = "GObject::Value"
|
174
196
|
|
175
197
|
def gvalue?
|
176
198
|
argument_class_name == GOBJECT_VALUE_NAME
|
@@ -220,4 +242,4 @@ module GirFFI
|
|
220
242
|
end
|
221
243
|
end
|
222
244
|
|
223
|
-
GObjectIntrospection::ITypeInfo.
|
245
|
+
GObjectIntrospection::ITypeInfo.include GirFFI::InfoExt::ITypeInfo
|
@@ -6,7 +6,7 @@ module GirFFI
|
|
6
6
|
module IValueInfo
|
7
7
|
def constant_name
|
8
8
|
upcased_name = name.upcase
|
9
|
-
if
|
9
|
+
if /^[0-9]/.match?(upcased_name)
|
10
10
|
"VALUE_#{upcased_name}"
|
11
11
|
else
|
12
12
|
upcased_name
|
@@ -22,4 +22,4 @@ module GirFFI
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
GObjectIntrospection::IValueInfo.
|
25
|
+
GObjectIntrospection::IValueInfo.include GirFFI::InfoExt::IValueInfo
|
@@ -16,7 +16,7 @@ module GirFFI
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def invoker_name
|
19
|
-
invoker
|
19
|
+
invoker&.name
|
20
20
|
end
|
21
21
|
|
22
22
|
def has_invoker?
|
@@ -26,4 +26,4 @@ module GirFFI
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
GObjectIntrospection::IVFuncInfo.
|
29
|
+
GObjectIntrospection::IVFuncInfo.include GirFFI::InfoExt::IVFuncInfo
|
@@ -5,10 +5,10 @@ module GirFFI
|
|
5
5
|
# Extension module provinding a #safe_name method suitable for types.
|
6
6
|
module SafeConstantName
|
7
7
|
def safe_name
|
8
|
-
name.tr(
|
8
|
+
name.tr("-", "_").sub(/^[_a-z]/) do |char|
|
9
9
|
case char
|
10
|
-
when
|
11
|
-
|
10
|
+
when "_"
|
11
|
+
"Private___"
|
12
12
|
else
|
13
13
|
char.upcase
|
14
14
|
end
|
@@ -18,8 +18,8 @@ module GirFFI
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
GObjectIntrospection::ICallbackInfo.
|
22
|
-
GObjectIntrospection::IConstantInfo.
|
23
|
-
GObjectIntrospection::IRegisteredTypeInfo.
|
24
|
-
GObjectIntrospection::ISignalInfo.
|
25
|
-
GObjectIntrospection::IVFuncInfo.
|
21
|
+
GObjectIntrospection::ICallbackInfo.include GirFFI::InfoExt::SafeConstantName
|
22
|
+
GObjectIntrospection::IConstantInfo.include GirFFI::InfoExt::SafeConstantName
|
23
|
+
GObjectIntrospection::IRegisteredTypeInfo.include GirFFI::InfoExt::SafeConstantName
|
24
|
+
GObjectIntrospection::ISignalInfo.include GirFFI::InfoExt::SafeConstantName
|
25
|
+
GObjectIntrospection::IVFuncInfo.include GirFFI::InfoExt::SafeConstantName
|
@@ -6,7 +6,7 @@ module GirFFI
|
|
6
6
|
module SafeFunctionName
|
7
7
|
def safe_name
|
8
8
|
name = self.name
|
9
|
-
return
|
9
|
+
return "_" if name.empty?
|
10
10
|
|
11
11
|
name
|
12
12
|
end
|
@@ -14,4 +14,4 @@ module GirFFI
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
GObjectIntrospection::IFunctionInfo.
|
17
|
+
GObjectIntrospection::IFunctionInfo.include GirFFI::InfoExt::SafeFunctionName
|
data/lib/gir_ffi/info_ext.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
3
|
+
require "gir_ffi/info_ext/full_type_name"
|
4
|
+
require "gir_ffi/info_ext/i_arg_info"
|
5
|
+
require "gir_ffi/info_ext/i_callable_info"
|
6
|
+
require "gir_ffi/info_ext/i_callback_info"
|
7
|
+
require "gir_ffi/info_ext/i_field_info"
|
8
|
+
require "gir_ffi/info_ext/i_function_info"
|
9
|
+
require "gir_ffi/info_ext/i_property_info"
|
10
|
+
require "gir_ffi/info_ext/i_registered_type_info"
|
11
|
+
require "gir_ffi/info_ext/i_signal_info"
|
12
|
+
require "gir_ffi/info_ext/i_type_info"
|
13
|
+
require "gir_ffi/info_ext/i_unresolved_info"
|
14
|
+
require "gir_ffi/info_ext/i_value_info"
|
15
|
+
require "gir_ffi/info_ext/i_vfunc_info"
|
16
|
+
require "gir_ffi/info_ext/safe_constant_name"
|
17
|
+
require "gir_ffi/info_ext/safe_function_name"
|