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
@@ -5,24 +5,30 @@ module GObjectIntrospection
|
|
5
5
|
# Represents type information, direction, transfer etc.
|
6
6
|
class ITypeInfo < IBaseInfo
|
7
7
|
def pointer?
|
8
|
-
|
8
|
+
return @pointer_eh if defined? @pointer_eh
|
9
|
+
|
10
|
+
@pointer_eh = Lib.g_type_info_is_pointer self
|
9
11
|
end
|
10
12
|
|
11
13
|
def tag
|
12
|
-
Lib.g_type_info_get_tag self
|
14
|
+
@tag ||= Lib.g_type_info_get_tag self
|
13
15
|
end
|
14
16
|
|
15
17
|
def param_type(index)
|
16
|
-
|
18
|
+
@param_type_cache ||= []
|
19
|
+
@param_type_cache[index] ||=
|
20
|
+
ITypeInfo.wrap Lib.g_type_info_get_param_type(self, index)
|
17
21
|
end
|
18
22
|
|
19
23
|
def interface
|
20
|
-
|
21
|
-
|
24
|
+
@interface ||= begin
|
25
|
+
ptr = Lib.g_type_info_get_interface self
|
26
|
+
IRepository.wrap_ibaseinfo_pointer ptr
|
27
|
+
end
|
22
28
|
end
|
23
29
|
|
24
30
|
def array_length
|
25
|
-
Lib.g_type_info_get_array_length self
|
31
|
+
@array_length ||= Lib.g_type_info_get_array_length self
|
26
32
|
end
|
27
33
|
|
28
34
|
def array_fixed_size
|
@@ -38,7 +44,7 @@ module GObjectIntrospection
|
|
38
44
|
end
|
39
45
|
|
40
46
|
def name
|
41
|
-
raise
|
47
|
+
raise "Should not call this for ITypeInfo"
|
42
48
|
end
|
43
49
|
end
|
44
50
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "ffi"
|
4
|
+
require "ffi/bit_masks"
|
5
5
|
|
6
6
|
module GObjectIntrospection
|
7
7
|
# Module for attaching functions from the girepository library
|
8
8
|
module Lib
|
9
9
|
extend FFI::Library
|
10
10
|
extend FFI::BitMasks
|
11
|
-
ffi_lib
|
11
|
+
ffi_lib "girepository-1.0"
|
12
12
|
|
13
13
|
# IRepository
|
14
14
|
enum :IRepositoryLoadFlags, [:LAZY, (1 << 0)]
|
@@ -116,24 +116,35 @@ module GObjectIntrospection
|
|
116
116
|
attach_function :g_arg_info_get_destroy, [:pointer], :int
|
117
117
|
attach_function :g_arg_info_get_type, [:pointer], :pointer
|
118
118
|
|
119
|
-
#
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
119
|
+
# ITypeTag
|
120
|
+
enum :ITypeTag, [
|
121
|
+
:void,
|
122
|
+
:gboolean,
|
123
|
+
:gint8,
|
124
|
+
:guint8,
|
125
|
+
:gint16,
|
126
|
+
:guint16,
|
127
|
+
:gint32,
|
128
|
+
:guint32,
|
129
|
+
:gint64,
|
130
|
+
:guint64,
|
131
|
+
:gfloat,
|
132
|
+
:gdouble,
|
133
|
+
:GType,
|
134
|
+
:utf8,
|
135
|
+
:filename,
|
136
|
+
:array,
|
137
|
+
:interface,
|
138
|
+
:glist,
|
139
|
+
:gslist,
|
140
|
+
:ghash,
|
141
|
+
:error,
|
142
|
+
:gunichar
|
143
|
+
]
|
144
|
+
|
135
145
|
attach_function :g_type_tag_to_string, [:ITypeTag], :string
|
136
146
|
|
147
|
+
# ITypeInfo
|
137
148
|
enum :IArrayType, [
|
138
149
|
:c,
|
139
150
|
:array,
|
@@ -1,26 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "ffi-gobject_introspection/gobject_type_init"
|
4
4
|
GObjectIntrospection::GObjectTypeInit.type_init
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
6
|
+
require "ffi-gobject_introspection/i_base_info"
|
7
|
+
require "ffi-gobject_introspection/i_callable_info"
|
8
|
+
require "ffi-gobject_introspection/i_callback_info"
|
9
|
+
require "ffi-gobject_introspection/i_function_info"
|
10
|
+
require "ffi-gobject_introspection/i_constant_info"
|
11
|
+
require "ffi-gobject_introspection/i_field_info"
|
12
|
+
require "ffi-gobject_introspection/i_registered_type_info"
|
13
|
+
require "ffi-gobject_introspection/i_interface_info"
|
14
|
+
require "ffi-gobject_introspection/i_property_info"
|
15
|
+
require "ffi-gobject_introspection/i_vfunc_info"
|
16
|
+
require "ffi-gobject_introspection/i_signal_info"
|
17
|
+
require "ffi-gobject_introspection/i_object_info"
|
18
|
+
require "ffi-gobject_introspection/i_struct_info"
|
19
|
+
require "ffi-gobject_introspection/i_value_info"
|
20
|
+
require "ffi-gobject_introspection/i_union_info"
|
21
|
+
require "ffi-gobject_introspection/i_enum_info"
|
22
|
+
require "ffi-gobject_introspection/i_flags_info"
|
23
|
+
require "ffi-gobject_introspection/i_unresolved_info"
|
24
24
|
|
25
25
|
module GObjectIntrospection
|
26
26
|
# Map info type to class. Default is IBaseInfo.
|
@@ -49,4 +49,4 @@ module GObjectIntrospection
|
|
49
49
|
}.freeze
|
50
50
|
end
|
51
51
|
|
52
|
-
require
|
52
|
+
require "ffi-gobject_introspection/i_repository"
|
data/lib/gir_ffi/arg_helper.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
3
|
+
require "gir_ffi/allocation_helper"
|
4
|
+
require "gir_ffi/builder"
|
5
|
+
require "gir_ffi/glib_error"
|
6
|
+
require "gir_ffi/object_store"
|
7
7
|
|
8
8
|
module GirFFI
|
9
9
|
# Helper module containing methods used during argument conversion in
|
@@ -1,29 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module GirFFI
|
4
|
-
# The
|
5
|
-
#
|
6
|
-
|
7
|
-
class InOutPointer < FFI::Pointer
|
4
|
+
# The ArrayElementConvertor class handles conversion from C array elements to
|
5
|
+
# ruby values
|
6
|
+
class ArrayElementConvertor
|
8
7
|
attr_reader :value_type
|
8
|
+
attr_reader :pointer
|
9
9
|
|
10
10
|
def initialize(type, ptr)
|
11
11
|
@value_type = type
|
12
|
-
|
12
|
+
@pointer = ptr
|
13
13
|
end
|
14
14
|
|
15
|
-
def to_value
|
16
|
-
case value_ffi_type
|
17
|
-
when Module
|
18
|
-
value_ffi_type.get_value_from_pointer(self, 0)
|
19
|
-
when Symbol
|
20
|
-
send("get_#{value_ffi_type}", 0)
|
21
|
-
else
|
22
|
-
raise NotImplementedError
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# Convert more fully to a ruby value than #to_value
|
27
15
|
def to_ruby_value
|
28
16
|
bare_value = to_value
|
29
17
|
case value_type
|
@@ -38,14 +26,19 @@ module GirFFI
|
|
38
26
|
end
|
39
27
|
end
|
40
28
|
|
41
|
-
def self.allocate_new(type)
|
42
|
-
ffi_type = TypeMap.type_specification_to_ffi_type type
|
43
|
-
ptr = FFI::MemoryPointer.new(ffi_type)
|
44
|
-
new type, ptr
|
45
|
-
end
|
46
|
-
|
47
29
|
private
|
48
30
|
|
31
|
+
def to_value
|
32
|
+
case value_ffi_type
|
33
|
+
when Module
|
34
|
+
value_ffi_type.get_value_from_pointer(pointer, 0)
|
35
|
+
when Symbol
|
36
|
+
pointer.send("get_#{value_ffi_type}", 0)
|
37
|
+
else
|
38
|
+
raise NotImplementedError
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
49
42
|
def value_ffi_type
|
50
43
|
@value_ffi_type ||= TypeMap.type_specification_to_ffi_type value_type
|
51
44
|
end
|
data/lib/gir_ffi/boolean.rb
CHANGED
data/lib/gir_ffi/boxed_base.rb
CHANGED
data/lib/gir_ffi/builder.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
3
|
+
require "gir_ffi/builders/type_builder"
|
4
|
+
require "gir_ffi/builders/module_builder"
|
5
|
+
require "gir_ffi/builder_helper"
|
6
|
+
require "gir_ffi/unintrospectable_type_info"
|
7
|
+
require "gir_ffi/unintrospectable_boxed_info"
|
8
8
|
|
9
9
|
module GirFFI
|
10
10
|
# Builds modules and classes based on information found in the
|
@@ -19,11 +19,17 @@ module GirFFI
|
|
19
19
|
|
20
20
|
def self.build_by_gtype(gtype)
|
21
21
|
info = GObjectIntrospection::IRepository.default.find_by_gtype gtype
|
22
|
-
info ||=
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
info ||= begin
|
23
|
+
fund = GObject.type_fundamental gtype
|
24
|
+
if fund == GObject::TYPE_BOXED
|
25
|
+
UnintrospectableBoxedInfo.new gtype
|
26
|
+
elsif fund == GObject::TYPE_OBJECT
|
27
|
+
UnintrospectableTypeInfo.new gtype
|
28
|
+
elsif fund >= GObject::TYPE_RESERVED_USER_FIRST
|
29
|
+
UnintrospectableTypeInfo.new gtype
|
30
|
+
else
|
31
|
+
raise "Unable to handle type #{GObject.type_name gtype}"
|
32
|
+
end
|
27
33
|
end
|
28
34
|
|
29
35
|
build_class info
|
@@ -36,6 +42,8 @@ module GirFFI
|
|
36
42
|
unless modul.const_defined? :GIR_FFI_BUILDER
|
37
43
|
raise "The module #{module_name} was already defined elsewhere"
|
38
44
|
end
|
45
|
+
|
46
|
+
return modul
|
39
47
|
end
|
40
48
|
Builders::ModuleBuilder.new(module_name,
|
41
49
|
namespace: namespace,
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
3
|
+
require "gir_ffi/builders/base_argument_builder"
|
4
|
+
require "gir_ffi/builders/closure_to_pointer_convertor"
|
5
|
+
require "gir_ffi/builders/full_c_to_ruby_convertor"
|
6
|
+
require "gir_ffi/builders/ruby_to_c_convertor"
|
7
|
+
require "gir_ffi/builders/pointer_value_convertor"
|
8
|
+
require "gir_ffi/builders/null_convertor"
|
9
9
|
|
10
10
|
module GirFFI
|
11
11
|
module Builders
|
@@ -114,7 +114,7 @@ module GirFFI
|
|
114
114
|
|
115
115
|
def outgoing_convertor(base)
|
116
116
|
FullCToRubyConvertor.new(type_info, base, length_argument_name,
|
117
|
-
ownership_transfer:
|
117
|
+
ownership_transfer: arginfo.ownership_transfer)
|
118
118
|
end
|
119
119
|
|
120
120
|
def sub_type_spec
|
@@ -138,11 +138,11 @@ module GirFFI
|
|
138
138
|
# is a pointer. For example, an out parameter of type gint8* will always
|
139
139
|
# be allocated by the caller (that's us).
|
140
140
|
def allocated_by_them?
|
141
|
-
|
141
|
+
!arginfo.caller_allocates? && type_info.pointer?
|
142
142
|
end
|
143
143
|
|
144
144
|
def length_argument_name
|
145
|
-
length_arg
|
145
|
+
length_arg&.post_converted_name
|
146
146
|
end
|
147
147
|
|
148
148
|
def needs_size_check?
|
@@ -155,12 +155,12 @@ module GirFFI
|
|
155
155
|
end
|
156
156
|
|
157
157
|
def skipped_in?
|
158
|
-
|
158
|
+
arginfo.skip?
|
159
159
|
end
|
160
160
|
|
161
161
|
def skipped_out?
|
162
|
-
|
163
|
-
|
162
|
+
arginfo.skip? ||
|
163
|
+
array_arg && array_arg.specialized_type_tag == :strv
|
164
164
|
end
|
165
165
|
|
166
166
|
def has_output_value?
|
@@ -176,7 +176,7 @@ module GirFFI
|
|
176
176
|
end
|
177
177
|
|
178
178
|
def array_length_assignment
|
179
|
-
arrname =
|
179
|
+
arrname = array_arg.name
|
180
180
|
"#{name} = #{arrname}.nil? ? 0 : #{arrname}.length"
|
181
181
|
end
|
182
182
|
|
@@ -200,14 +200,14 @@ module GirFFI
|
|
200
200
|
|
201
201
|
def caller_allocated_object?
|
202
202
|
[:struct, :array].include?(specialized_type_tag) &&
|
203
|
-
|
203
|
+
arginfo.caller_allocates?
|
204
204
|
end
|
205
205
|
|
206
|
-
DESTROY_NOTIFIER =
|
206
|
+
DESTROY_NOTIFIER = "GLib::DestroyNotify.default"
|
207
207
|
|
208
208
|
def ingoing_convertor
|
209
209
|
if skipped_in?
|
210
|
-
NullConvertor.new(
|
210
|
+
NullConvertor.new("0")
|
211
211
|
elsif destroy_notifier?
|
212
212
|
NullConvertor.new(DESTROY_NOTIFIER)
|
213
213
|
elsif user_data?
|
@@ -233,7 +233,7 @@ module GirFFI
|
|
233
233
|
end
|
234
234
|
|
235
235
|
def callback_argument_name
|
236
|
-
|
236
|
+
related_callback_builder.call_argument_name
|
237
237
|
end
|
238
238
|
end
|
239
239
|
end
|