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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99e99f94ba677daacfe98552b91f5221dea70d33dd992ac53e223e4ff05df898
|
4
|
+
data.tar.gz: d83b543e6408259e2fa9067faa74c393e117e94148a7d37b7825cfe840537d8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '02840b2cb293bd64f478f023d7267d20f37f35c24a3a15c9569a04e8f4095cb297d5e9319bd55f1105d8d4cd961c9cab7cc2b01092b1c822f04dab7dc70e9023'
|
7
|
+
data.tar.gz: 331e901b2c3c94800ad52576dd9127563ae9d41657f947be0543f7ad765e55d0bd64b2ad7642c58b6e36f243d4f5d719047de6d10d15c369cbc49e724b378bd4
|
data/Changelog.md
CHANGED
@@ -1,5 +1,26 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.15.0 / 2019-10-19
|
4
|
+
|
5
|
+
* Drop support for gobject-introspection below 1.46, the version available in
|
6
|
+
Ubuntu Xenial.
|
7
|
+
* Merge extended property getter and setter into regular ones. This means you
|
8
|
+
can always just use `#get_property` and `#set_property`. The methods
|
9
|
+
`#get_property_extended` and `#set_property_extended` are deprecated and will
|
10
|
+
be removed in GirFFI version 0.16 or later.
|
11
|
+
* Support setting ByteArray properties directly with string values.
|
12
|
+
* Target Ruby 2.4+
|
13
|
+
* Implement getting and setting of flag properties and GValues.
|
14
|
+
* Add support for basic hashtable values larger than pointer.
|
15
|
+
* Support unintrospectable classes not derived from GObject but from some other
|
16
|
+
fundamental object type.
|
17
|
+
* Make GPtrArray work with boxed types.
|
18
|
+
* Do not try to ref method reciever for struct instance methods marking the
|
19
|
+
instance receiver as transfer `:everything`.
|
20
|
+
* Support signals with GError arguments.
|
21
|
+
* Cache various methods on IBaseInfo and its subclasses.
|
22
|
+
* Generate aliases for accessor methods instead of relying on `method_missing`.
|
23
|
+
|
3
24
|
## 0.14.1 / 2018-09-27
|
4
25
|
|
5
26
|
* Add enum values as constants in the generated module.
|
data/Gemfile
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
source
|
3
|
+
source "https://rubygems.org"
|
4
4
|
|
5
5
|
# The gem's dependencies are specified in gir_ffi.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
gem
|
8
|
+
gem "pry", "~> 0.12.0"
|
9
|
+
gem "ruby-prof", platform: :mri
|
10
|
+
gem "test-prof", platform: :mri
|
9
11
|
|
10
|
-
if ENV[
|
11
|
-
gem
|
12
|
+
if ENV["CI"]
|
13
|
+
gem "coveralls", group: :development if ENV["TRAVIS_RUBY_VERSION"] == "2.4"
|
12
14
|
end
|
data/README.md
CHANGED
@@ -53,7 +53,7 @@ examples can be found in `gir_ffi-gtk` and `gir_ffi-gst`.
|
|
53
53
|
|
54
54
|
## Requirements
|
55
55
|
|
56
|
-
GirFFI is supported on CRuby 2.
|
56
|
+
GirFFI is supported on CRuby 2.4, 2.5 and 2.6, and JRuby 9.2.
|
57
57
|
|
58
58
|
You will also need gobject-introspection installed with some
|
59
59
|
introspection data.
|
@@ -63,15 +63,15 @@ available under the name ending in plain `.so`. If GirFFI complains that it
|
|
63
63
|
cannot find the library, try installing development packages for those
|
64
64
|
libraries.
|
65
65
|
|
66
|
-
GirFFI should work with gobject-introspection 1.
|
66
|
+
GirFFI should work with gobject-introspection 1.46.0 and up.
|
67
67
|
|
68
68
|
On Debian and Ubuntu, installing `libgirepository1.0-1` and `gir1.2-glib-2.0`
|
69
69
|
should be enough to use GirFFI in your application.
|
70
70
|
|
71
71
|
To run the tests, you should additionally install `libgirepository1.0-dev`,
|
72
72
|
`libcairo2-dev`, `gobject-introspection`, `gir1.2-gtop-2.0`, `gir1.2-gtk-3.0`,
|
73
|
-
`gir1.2-
|
74
|
-
be enough to get `rake test` working.
|
73
|
+
`gir1.2-gtksource-3.0`, `gir1.2-pango-1.0`, `gir1.2-secret-1` and
|
74
|
+
`gir1.2-gstreamer-1.0`. This should be enough to get `rake test` working.
|
75
75
|
|
76
76
|
GirFFI has not been tested on Mac OS X or Microsoft Windows. YMMV.
|
77
77
|
|
data/Rakefile
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "rake/clean"
|
4
|
+
require "bundler/gem_tasks"
|
5
5
|
|
6
|
-
load
|
6
|
+
load "tasks/test.rake"
|
7
7
|
|
8
|
-
task default:
|
9
|
-
task default:
|
8
|
+
task default: "test:all"
|
9
|
+
task default: "test:features"
|
data/lib/ffi-glib/array.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "ffi-glib/container_class_methods"
|
4
|
+
require "gir_ffi/array_element_convertor"
|
5
5
|
|
6
6
|
GLib.load_class :Array
|
7
7
|
|
@@ -10,7 +10,6 @@ module GLib
|
|
10
10
|
# be necessary to create objects of this class from Ruby directly.
|
11
11
|
class Array
|
12
12
|
include Enumerable
|
13
|
-
include ArrayMethods
|
14
13
|
extend ContainerClassMethods
|
15
14
|
|
16
15
|
attr_reader :element_type
|
@@ -70,6 +69,17 @@ module GLib
|
|
70
69
|
self
|
71
70
|
end
|
72
71
|
|
72
|
+
# Re-implementation of the g_array_index macro
|
73
|
+
def index(idx)
|
74
|
+
unless (0...length).cover? idx
|
75
|
+
raise IndexError, "Index #{idx} outside of bounds 0..#{length - 1}"
|
76
|
+
end
|
77
|
+
|
78
|
+
item_ptr = data_ptr + idx * element_size
|
79
|
+
convertor = GirFFI::ArrayElementConvertor.new element_type, item_ptr
|
80
|
+
convertor.to_ruby_value
|
81
|
+
end
|
82
|
+
|
73
83
|
private
|
74
84
|
|
75
85
|
def data_ptr
|
@@ -83,7 +93,7 @@ module GLib
|
|
83
93
|
def check_element_size_match
|
84
94
|
return if calculated_element_size == get_element_size
|
85
95
|
|
86
|
-
warn
|
96
|
+
warn "WARNING: Element sizes do not match"
|
87
97
|
end
|
88
98
|
|
89
99
|
def guess_element_type
|
data/lib/ffi-glib/byte_array.rb
CHANGED
@@ -15,8 +15,13 @@ module GLib
|
|
15
15
|
self.class.wrap Lib.g_byte_array_append(to_ptr, bytes, len)
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
|
18
|
+
def self.from(data)
|
19
|
+
case data
|
20
|
+
when self
|
21
|
+
data
|
22
|
+
else
|
23
|
+
new.append(data)
|
24
|
+
end
|
20
25
|
end
|
21
26
|
end
|
22
27
|
end
|
data/lib/ffi-glib/error.rb
CHANGED
@@ -5,7 +5,7 @@ GLib.load_class :Error
|
|
5
5
|
module GLib
|
6
6
|
# Overrides for GError, used by GLib for handling non-fatal errors.
|
7
7
|
class Error
|
8
|
-
GIR_FFI_DOMAIN = GLib.quark_from_string(
|
8
|
+
GIR_FFI_DOMAIN = GLib.quark_from_string("gir_ffi")
|
9
9
|
|
10
10
|
def self.from_exception(exception)
|
11
11
|
new_literal GIR_FFI_DOMAIN, 0, exception.message
|
data/lib/ffi-glib/hash_table.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "ffi-glib/container_class_methods"
|
4
4
|
|
5
5
|
GLib.load_class :HashTable
|
6
6
|
|
@@ -63,7 +63,7 @@ module GLib
|
|
63
63
|
when :utf8
|
64
64
|
FFI::Function.new(:uint,
|
65
65
|
[:pointer],
|
66
|
-
find_support_function(
|
66
|
+
find_support_function("g_str_hash"))
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -72,7 +72,7 @@ module GLib
|
|
72
72
|
when :utf8
|
73
73
|
FFI::Function.new(:int,
|
74
74
|
[:pointer, :pointer],
|
75
|
-
find_support_function(
|
75
|
+
find_support_function("g_str_equal"))
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
data/lib/ffi-glib/list.rb
CHANGED
data/lib/ffi-glib/main_loop.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "singleton"
|
4
4
|
|
5
5
|
GLib.load_class :MainLoop
|
6
6
|
|
@@ -40,7 +40,7 @@ module GLib
|
|
40
40
|
setup_instance_method! :run
|
41
41
|
|
42
42
|
def run_with_thread_enabler
|
43
|
-
ThreadEnabler.instance.setup_idle_handler if RUBY_ENGINE ==
|
43
|
+
ThreadEnabler.instance.setup_idle_handler if RUBY_ENGINE == "ruby"
|
44
44
|
RUNNING_LOOPS << self
|
45
45
|
result = run_without_thread_enabler
|
46
46
|
exception = EXCEPTIONS.shift
|
@@ -63,6 +63,6 @@ module GLib
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
Signal.trap
|
66
|
+
Signal.trap "INT" do
|
67
67
|
GLib::MainLoop.handle_exception(Interrupt.new)
|
68
68
|
end
|
data/lib/ffi-glib/ptr_array.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "ffi-glib/container_class_methods"
|
4
|
+
require "gir_ffi/array_element_convertor"
|
5
5
|
|
6
6
|
GLib.load_class :PtrArray
|
7
7
|
|
@@ -10,7 +10,6 @@ module GLib
|
|
10
10
|
# pointers.
|
11
11
|
class PtrArray
|
12
12
|
include Enumerable
|
13
|
-
include ArrayMethods
|
14
13
|
extend ContainerClassMethods
|
15
14
|
|
16
15
|
attr_reader :element_type
|
@@ -49,12 +48,25 @@ module GLib
|
|
49
48
|
ary.each { |item| add item }
|
50
49
|
end
|
51
50
|
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
# Re-implementation of the g_ptrarray_index macro
|
52
|
+
def index(idx)
|
53
|
+
unless (0...length).cover? idx
|
54
|
+
raise IndexError, "Index #{idx} outside of bounds 0..#{length - 1}"
|
55
|
+
end
|
55
56
|
|
56
|
-
|
57
|
-
|
57
|
+
item_ptr = data_ptr + idx * element_size
|
58
|
+
|
59
|
+
convert_element_type = case element_type
|
60
|
+
when :utf8
|
61
|
+
:utf8
|
62
|
+
when GirFFI::ObjectBase
|
63
|
+
element_type
|
64
|
+
else
|
65
|
+
[:pointer, element_type]
|
66
|
+
end
|
67
|
+
|
68
|
+
convertor = GirFFI::ArrayElementConvertor.new convert_element_type, item_ptr
|
69
|
+
convertor.to_ruby_value
|
58
70
|
end
|
59
71
|
|
60
72
|
def each
|
@@ -70,5 +82,15 @@ module GLib
|
|
70
82
|
def ==(other)
|
71
83
|
to_a == other.to_a
|
72
84
|
end
|
85
|
+
|
86
|
+
private
|
87
|
+
|
88
|
+
def element_size
|
89
|
+
POINTER_SIZE
|
90
|
+
end
|
91
|
+
|
92
|
+
def data_ptr
|
93
|
+
struct[:pdata]
|
94
|
+
end
|
73
95
|
end
|
74
96
|
end
|
data/lib/ffi-glib/s_list.rb
CHANGED
data/lib/ffi-glib/variant.rb
CHANGED
data/lib/ffi-glib.rb
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Ensure GLib is defined by GirFFI itself
|
4
|
-
raise
|
4
|
+
raise "The module GLib was already defined elsewhere" if Kernel.const_defined? :GLib
|
5
5
|
|
6
|
-
require
|
6
|
+
require "gir_ffi/core"
|
7
7
|
|
8
8
|
# Bypass check for existing modules
|
9
|
-
GirFFI::Builders::ModuleBuilder.new(
|
10
|
-
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
9
|
+
GirFFI::Builders::ModuleBuilder.new("GLib").generate
|
10
|
+
|
11
|
+
require "ffi-glib/array"
|
12
|
+
require "ffi-glib/byte_array"
|
13
|
+
require "ffi-glib/bytes"
|
14
|
+
require "ffi-glib/destroy_notify"
|
15
|
+
require "ffi-glib/error"
|
16
|
+
require "ffi-glib/hash_table"
|
17
|
+
require "ffi-glib/list"
|
18
|
+
require "ffi-glib/main_loop"
|
19
|
+
require "ffi-glib/ptr_array"
|
20
|
+
require "ffi-glib/s_list"
|
21
|
+
require "ffi-glib/strv"
|
22
|
+
require "ffi-glib/variant"
|
23
23
|
|
24
24
|
# Module representing GLib's GLib namespace.
|
25
25
|
module GLib
|
data/lib/ffi-gobject/object.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "gir_ffi/property_not_found_error"
|
4
4
|
|
5
5
|
GObject.load_class :Object
|
6
6
|
|
@@ -44,7 +44,7 @@ module GObject
|
|
44
44
|
obj
|
45
45
|
end
|
46
46
|
else
|
47
|
-
setup_method!
|
47
|
+
setup_method! "new"
|
48
48
|
|
49
49
|
# Before GLib 2.54.0, use g_object_newv, which takes an array of GParameter.
|
50
50
|
def initialize_with_automatic_gtype(properties = {})
|
@@ -90,22 +90,6 @@ module GObject
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
# TODO: Generate accessor methods from GIR at class definition time
|
94
|
-
def method_missing(method, *args)
|
95
|
-
getter_name = "get_#{method}"
|
96
|
-
return send(getter_name, *args) if respond_to?(getter_name)
|
97
|
-
|
98
|
-
if method.to_s =~ /(.*)=$/
|
99
|
-
setter_name = "set_#{Regexp.last_match[1]}"
|
100
|
-
return send(setter_name, *args) if respond_to?(setter_name)
|
101
|
-
end
|
102
|
-
super
|
103
|
-
end
|
104
|
-
|
105
|
-
def respond_to_missing?(*)
|
106
|
-
false
|
107
|
-
end
|
108
|
-
|
109
93
|
def signal_connect(event, data = nil, &block)
|
110
94
|
GObject.signal_connect(self, event, data, &block)
|
111
95
|
end
|
@@ -114,30 +98,37 @@ module GObject
|
|
114
98
|
GObject.signal_connect_after(self, event, data, &block)
|
115
99
|
end
|
116
100
|
|
117
|
-
setup_instance_method!
|
118
|
-
setup_instance_method!
|
101
|
+
setup_instance_method! "get_property"
|
102
|
+
setup_instance_method! "set_property"
|
119
103
|
|
104
|
+
# @deprecated
|
120
105
|
def get_property_extended(property_name)
|
121
|
-
|
122
|
-
type_info = get_property_type property_name
|
123
|
-
property_value_post_conversion value, type_info
|
106
|
+
get_property(property_name)
|
124
107
|
end
|
125
108
|
|
126
109
|
def get_property_with_override(property_name)
|
127
110
|
gvalue = gvalue_for_property property_name
|
128
111
|
get_property_without_override property_name, gvalue
|
129
|
-
gvalue.get_value
|
112
|
+
value = gvalue.get_value
|
113
|
+
|
114
|
+
type_info = get_property_type property_name
|
115
|
+
value = property_value_post_conversion(value, type_info) if type_info
|
116
|
+
|
117
|
+
value
|
130
118
|
end
|
131
119
|
|
120
|
+
# @deprecated
|
132
121
|
def set_property_extended(property_name, value)
|
133
|
-
|
134
|
-
adjusted_value = property_value_pre_conversion(value, type_info)
|
135
|
-
set_property property_name, adjusted_value
|
122
|
+
set_property property_name, value
|
136
123
|
end
|
137
124
|
|
138
125
|
def set_property_with_override(property_name, value)
|
126
|
+
type_info = get_property_type property_name
|
127
|
+
value = property_value_pre_conversion(value, type_info) if type_info
|
128
|
+
|
139
129
|
gvalue = gvalue_for_property(property_name)
|
140
130
|
gvalue.set_value value
|
131
|
+
|
141
132
|
set_property_without_override property_name, gvalue
|
142
133
|
end
|
143
134
|
|
@@ -147,7 +138,7 @@ module GObject
|
|
147
138
|
alias set_property_without_override set_property
|
148
139
|
alias set_property set_property_with_override
|
149
140
|
|
150
|
-
setup_instance_method!
|
141
|
+
setup_instance_method! "is_floating"
|
151
142
|
alias floating? is_floating
|
152
143
|
|
153
144
|
private
|
@@ -165,8 +156,7 @@ module GObject
|
|
165
156
|
end
|
166
157
|
|
167
158
|
def get_property_type(property_name)
|
168
|
-
|
169
|
-
prop.property_type
|
159
|
+
self.class.find_property(property_name)&.property_type
|
170
160
|
end
|
171
161
|
|
172
162
|
def gvalue_for_property(property_name)
|
@@ -175,8 +165,7 @@ module GObject
|
|
175
165
|
end
|
176
166
|
|
177
167
|
def property_gtype(property_name)
|
178
|
-
|
179
|
-
pspec.value_type
|
168
|
+
property_param_spec(property_name).value_type
|
180
169
|
end
|
181
170
|
|
182
171
|
def property_param_spec(property_name)
|
@@ -207,6 +196,8 @@ module GObject
|
|
207
196
|
GLib::List.from type_info.element_type, val
|
208
197
|
when :strv
|
209
198
|
GLib::Strv.from val
|
199
|
+
when :byte_array
|
200
|
+
GLib::ByteArray.from val
|
210
201
|
when :callback
|
211
202
|
GirFFI::Builder.build_class(type_info.interface).from val
|
212
203
|
else
|