gir_ffi 0.7.10 → 0.8.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 +6 -0
- data/Gemfile +3 -1
- data/README.md +5 -2
- data/lib/ffi-glib.rb +1 -0
- data/lib/ffi-glib/array.rb +6 -6
- data/lib/ffi-glib/array_methods.rb +1 -1
- data/lib/ffi-glib/byte_array.rb +1 -1
- data/lib/ffi-glib/bytes.rb +3 -3
- data/lib/ffi-glib/container_class_methods.rb +2 -2
- data/lib/ffi-glib/error.rb +2 -2
- data/lib/ffi-glib/hash_table.rb +9 -9
- data/lib/ffi-glib/iconv.rb +1 -1
- data/lib/ffi-glib/list.rb +2 -2
- data/lib/ffi-glib/list_methods.rb +8 -7
- data/lib/ffi-glib/main_loop.rb +1 -1
- data/lib/ffi-glib/ptr_array.rb +7 -7
- data/lib/ffi-glib/s_list.rb +2 -2
- data/lib/ffi-glib/strv.rb +3 -3
- data/lib/ffi-glib/variant.rb +9 -2
- data/lib/ffi-gobject.rb +10 -10
- data/lib/ffi-gobject/closure.rb +1 -1
- data/lib/ffi-gobject/initially_unowned.rb +4 -3
- data/lib/ffi-gobject/object.rb +19 -19
- data/lib/ffi-gobject/object_class.rb +2 -2
- data/lib/ffi-gobject/ruby_closure.rb +5 -4
- data/lib/ffi-gobject/value.rb +15 -20
- data/lib/ffi-gobject_introspection/g_error.rb +1 -1
- data/lib/ffi-gobject_introspection/i_base_info.rb +6 -6
- data/lib/ffi-gobject_introspection/i_callable_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_enum_info.rb +2 -2
- data/lib/ffi-gobject_introspection/i_interface_info.rb +8 -8
- data/lib/ffi-gobject_introspection/i_object_info.rb +9 -9
- data/lib/ffi-gobject_introspection/i_repository.rb +13 -13
- data/lib/ffi-gobject_introspection/i_struct_info.rb +2 -2
- data/lib/ffi-gobject_introspection/i_type_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_union_info.rb +3 -3
- data/lib/ffi-gobject_introspection/lib.rb +4 -4
- data/lib/gir_ffi-base/glib/boolean.rb +4 -4
- data/lib/gir_ffi-base/glib/strv.rb +2 -2
- data/lib/gir_ffi/allocation_helper.rb +1 -1
- data/lib/gir_ffi/arg_helper.rb +8 -8
- data/lib/gir_ffi/boxed_base.rb +5 -9
- data/lib/gir_ffi/builder.rb +4 -4
- data/lib/gir_ffi/builder_helper.rb +3 -3
- data/lib/gir_ffi/builders/argument_builder_collection.rb +1 -1
- data/lib/gir_ffi/builders/base_argument_builder.rb +3 -3
- data/lib/gir_ffi/builders/base_method_builder.rb +71 -0
- data/lib/gir_ffi/builders/base_type_builder.rb +1 -1
- data/lib/gir_ffi/builders/boxed_builder.rb +3 -2
- data/lib/gir_ffi/builders/c_to_ruby_convertor.rb +1 -1
- data/lib/gir_ffi/builders/closure_convertor.rb +1 -1
- data/lib/gir_ffi/builders/closure_to_pointer_convertor.rb +1 -1
- data/lib/gir_ffi/builders/constructor_builder.rb +52 -0
- data/lib/gir_ffi/builders/enum_builder.rb +3 -3
- data/lib/gir_ffi/builders/field_builder.rb +3 -2
- data/lib/gir_ffi/builders/function_builder.rb +9 -50
- data/lib/gir_ffi/builders/initializer_builder.rb +32 -0
- data/lib/gir_ffi/builders/initializer_return_value_builder.rb +16 -0
- data/lib/gir_ffi/builders/mapping_method_builder.rb +7 -5
- data/lib/gir_ffi/builders/marshalling_method_builder.rb +5 -3
- data/lib/gir_ffi/builders/method_template.rb +1 -1
- data/lib/gir_ffi/builders/module_builder.rb +8 -7
- data/lib/gir_ffi/builders/null_convertor.rb +1 -1
- data/lib/gir_ffi/builders/null_return_value_builder.rb +21 -0
- data/lib/gir_ffi/builders/object_builder.rb +3 -3
- data/lib/gir_ffi/builders/property_builder.rb +1 -1
- data/lib/gir_ffi/builders/registered_type_builder.rb +31 -15
- data/lib/gir_ffi/builders/return_value_builder.rb +1 -14
- data/lib/gir_ffi/builders/ruby_to_c_convertor.rb +2 -2
- data/lib/gir_ffi/builders/signal_closure_builder.rb +1 -1
- data/lib/gir_ffi/builders/type_builder.rb +2 -2
- data/lib/gir_ffi/builders/unintrospectable_builder.rb +1 -1
- data/lib/gir_ffi/builders/user_defined_builder.rb +11 -11
- data/lib/gir_ffi/builders/vfunc_builder.rb +1 -1
- data/lib/gir_ffi/callback_base.rb +8 -13
- data/lib/gir_ffi/class_base.rb +41 -45
- data/lib/gir_ffi/core.rb +2 -2
- data/lib/gir_ffi/enum_base.rb +9 -14
- data/lib/gir_ffi/field_argument_info.rb +1 -1
- data/lib/gir_ffi/g_type.rb +1 -1
- data/lib/gir_ffi/glib_error.rb +1 -1
- data/lib/gir_ffi/in_out_pointer.rb +4 -4
- data/lib/gir_ffi/in_pointer.rb +12 -12
- data/lib/gir_ffi/info_ext/i_arg_info.rb +0 -10
- data/lib/gir_ffi/info_ext/i_callback_info.rb +0 -5
- data/lib/gir_ffi/info_ext/i_property_info.rb +1 -1
- data/lib/gir_ffi/info_ext/i_registered_type_info.rb +1 -6
- data/lib/gir_ffi/info_ext/i_signal_info.rb +2 -2
- data/lib/gir_ffi/info_ext/i_type_info.rb +2 -17
- data/lib/gir_ffi/info_ext/i_unresolved_info.rb +0 -5
- data/lib/gir_ffi/info_ext/i_vfunc_info.rb +2 -2
- data/lib/gir_ffi/interface_base.rb +2 -7
- data/lib/gir_ffi/method_stubber.rb +1 -1
- data/lib/gir_ffi/module_base.rb +4 -7
- data/lib/gir_ffi/object_base.rb +4 -9
- data/lib/gir_ffi/receiver_argument_info.rb +1 -1
- data/lib/gir_ffi/receiver_type_info.rb +1 -1
- data/lib/gir_ffi/registered_type_base.rb +0 -5
- data/lib/gir_ffi/return_value_info.rb +1 -1
- data/lib/gir_ffi/sized_array.rb +10 -10
- data/lib/gir_ffi/type_map.rb +3 -3
- data/lib/gir_ffi/unintrospectable_type_info.rb +3 -1
- data/lib/gir_ffi/user_data_argument_info.rb +1 -1
- data/lib/gir_ffi/user_defined_property_info.rb +1 -1
- data/lib/gir_ffi/user_defined_type_info.rb +4 -4
- data/lib/gir_ffi/version.rb +1 -1
- data/lib/gir_ffi/vfunc_implementation.rb +1 -1
- data/lib/gir_ffi/zero_terminated.rb +6 -6
- data/test/base_test_helper.rb +13 -13
- data/test/ffi-gobject/object_test.rb +22 -1
- data/test/ffi-gobject/value_test.rb +24 -24
- data/test/ffi-gobject_introspection/i_registered_type_info_test.rb +4 -4
- data/test/ffi-gobject_introspection/i_type_info_test.rb +2 -2
- data/test/ffi-gobject_test.rb +2 -2
- data/test/gir_ffi/builders/argument_builder_test.rb +60 -60
- data/test/gir_ffi/builders/callback_argument_builder_test.rb +8 -8
- data/test/gir_ffi/builders/callback_builder_test.rb +4 -4
- data/test/gir_ffi/builders/callback_return_value_builder_test.rb +8 -8
- data/test/gir_ffi/builders/constructor_builder_test.rb +34 -0
- data/test/gir_ffi/builders/function_builder_test.rb +8 -24
- data/test/gir_ffi/builders/initializer_builder_test.rb +36 -0
- data/test/gir_ffi/builders/interface_builder_test.rb +2 -2
- data/test/gir_ffi/builders/object_builder_test.rb +6 -18
- data/test/gir_ffi/builders/property_builder_test.rb +2 -2
- data/test/gir_ffi/builders/return_value_builder_test.rb +54 -79
- data/test/gir_ffi/builders/signal_closure_builder_test.rb +14 -14
- data/test/gir_ffi/builders/user_defined_builder_test.rb +8 -8
- data/test/gir_ffi/builders/vfunc_builder_test.rb +22 -22
- data/test/gir_ffi/class_base_test.rb +9 -7
- data/test/gir_ffi/in_pointer_test.rb +1 -1
- data/test/gir_ffi/info_ext/i_callable_info_test.rb +2 -2
- data/test/gir_ffi/info_ext/i_callback_info_test.rb +2 -2
- data/test/gir_ffi/info_ext/i_field_info_test.rb +2 -2
- data/test/gir_ffi/info_ext/i_function_info_test.rb +2 -2
- data/test/gir_ffi/info_ext/i_signal_info_test.rb +2 -2
- data/test/gir_ffi/info_ext/i_type_info_test.rb +18 -18
- data/test/gir_ffi/info_ext/i_unresolved_info_test.rb +2 -2
- data/test/gir_ffi/info_ext/safe_constant_name_test.rb +2 -2
- data/test/gir_ffi/info_ext/safe_function_name_test.rb +2 -2
- data/test/gir_ffi/method_stubber_test.rb +6 -6
- data/test/gir_ffi/user_defined_type_info_test.rb +3 -3
- data/test/gir_ffi_test_helper.rb +12 -12
- data/test/integration/derived_classes_test.rb +7 -3
- data/test/integration/generated_gimarshallingtests_test.rb +10 -10
- data/test/integration/generated_regress_test.rb +11 -20
- data/test/introspection_test_helper.rb +1 -1
- data/test/minitest/stats_plugin.rb +3 -3
- metadata +9 -3
- data/lib/gir_ffi/builders/constructor_result_convertor.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3de30b661f43f74216127542e5c68adc520c2fae
|
4
|
+
data.tar.gz: d517d1dd678fa2e4c5fb13547c6a225286afce44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66971838b0f54a2d34b24ac782564a09cfd675236520a4212ec41af35acea4fa3ab212daab633b29b8af83d3af0a12b736656d4a50f032cd432d4dca831a4bba
|
7
|
+
data.tar.gz: 3a419c93f07af1e2781fb2afc2d6e4a057bbbd0802acd99d0a9ce3afea146520050615e826d38778a6e07b5edc494e792568b61f06d970caadcff4599e2d8f09
|
data/Changelog.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.8.0 / 2015-09-18
|
4
|
+
|
5
|
+
* Drop official support for CRuby 1.9.3
|
6
|
+
* Officially support JRuby 9.0.0.0
|
7
|
+
* Change handling of initializers in custom subclasses
|
8
|
+
|
3
9
|
## 0.7.10 / 2015-09-16
|
4
10
|
|
5
11
|
* Allow ffi-gobject and ffi-glib to be required directly
|
data/Gemfile
CHANGED
@@ -4,7 +4,9 @@ source 'https://rubygems.org'
|
|
4
4
|
gemspec
|
5
5
|
|
6
6
|
if ENV['CI']
|
7
|
-
|
7
|
+
if ENV['TRAVIS_RUBY_VERSION'] == '2.2'
|
8
|
+
gem 'coveralls', type: :development
|
9
|
+
end
|
8
10
|
else
|
9
11
|
gem 'simplecov', '~> 0.10.0', type: :development, platform: :mri
|
10
12
|
gem 'pry', '~> 0.10.0', type: :development
|
data/README.md
CHANGED
@@ -40,14 +40,17 @@ Ruby bindings for GNOME using the GObject Introspection Repository.
|
|
40
40
|
# Call a function in the namespace
|
41
41
|
Gio.dbus_is_name "foo" # => false
|
42
42
|
|
43
|
+
See the [documentation](docs/Documentation.md) for more usage information.
|
44
|
+
|
43
45
|
## Install
|
44
46
|
|
45
47
|
gem install gir_ffi
|
46
48
|
|
47
49
|
## Requirements
|
48
50
|
|
49
|
-
GirFFI should work on CRuby
|
50
|
-
and on Rubinius.
|
51
|
+
GirFFI should work on CRuby 2.0.0, 2.1 and 2.2, JRuby 1.7.x in 1.9 or 2.0 mode,
|
52
|
+
JRuby 9.0.0.0, and on Rubinius. If you need support for CRuby 1.9.3, use
|
53
|
+
version 0.7.10.
|
51
54
|
|
52
55
|
You will also need gobject-introspection installed with some
|
53
56
|
introspection data.
|
data/lib/ffi-glib.rb
CHANGED
data/lib/ffi-glib/array.rb
CHANGED
@@ -15,24 +15,24 @@ module GLib
|
|
15
15
|
|
16
16
|
class << self; undef :new; end
|
17
17
|
|
18
|
-
def self.new
|
18
|
+
def self.new(type)
|
19
19
|
ptr = Lib.g_array_new(0, 0, calculated_element_size(type))
|
20
20
|
wrap type, ptr
|
21
21
|
end
|
22
22
|
|
23
23
|
# @api private
|
24
|
-
def self.from_enumerable
|
24
|
+
def self.from_enumerable(elmtype, it)
|
25
25
|
new(elmtype).tap { |arr| arr.append_vals it }
|
26
26
|
end
|
27
27
|
|
28
28
|
# @api private
|
29
|
-
def self.calculated_element_size
|
29
|
+
def self.calculated_element_size(type)
|
30
30
|
ffi_type = GirFFI::TypeMap.type_specification_to_ffi_type(type)
|
31
31
|
FFI.type_size(ffi_type)
|
32
32
|
end
|
33
33
|
|
34
34
|
# @override
|
35
|
-
def append_vals
|
35
|
+
def append_vals(ary)
|
36
36
|
bytes = GirFFI::InPointer.from_array element_type, ary
|
37
37
|
Lib.g_array_append_vals(self, bytes, ary.length)
|
38
38
|
self
|
@@ -54,12 +54,12 @@ module GLib
|
|
54
54
|
|
55
55
|
alias_method :element_size, :get_element_size
|
56
56
|
|
57
|
-
def ==
|
57
|
+
def ==(other)
|
58
58
|
to_a == other.to_a
|
59
59
|
end
|
60
60
|
|
61
61
|
# @api private
|
62
|
-
def reset_typespec
|
62
|
+
def reset_typespec(typespec = nil)
|
63
63
|
if typespec
|
64
64
|
@element_type = typespec
|
65
65
|
check_element_size_match
|
@@ -2,7 +2,7 @@ module GLib
|
|
2
2
|
# Common methods for GLib::Array and GLib::PtrArray
|
3
3
|
module ArrayMethods
|
4
4
|
# Re-implementation of the g_array_index and g_ptr_array_index macros
|
5
|
-
def index
|
5
|
+
def index(idx)
|
6
6
|
if idx >= length || idx < 0
|
7
7
|
raise IndexError, "Index #{idx} outside of bounds 0..#{length - 1}"
|
8
8
|
end
|
data/lib/ffi-glib/byte_array.rb
CHANGED
data/lib/ffi-glib/bytes.rb
CHANGED
@@ -17,11 +17,11 @@ module GLib
|
|
17
17
|
GirFFI::SizedArray.wrap(:guint8, length, data_ptr)
|
18
18
|
end
|
19
19
|
|
20
|
-
def each
|
20
|
+
def each(&block)
|
21
21
|
data.each(&block)
|
22
22
|
end
|
23
23
|
|
24
|
-
def self.from
|
24
|
+
def self.from(it)
|
25
25
|
case it
|
26
26
|
when self
|
27
27
|
it
|
@@ -36,7 +36,7 @@ module GLib
|
|
36
36
|
undef new
|
37
37
|
end
|
38
38
|
|
39
|
-
def self.new
|
39
|
+
def self.new(arr)
|
40
40
|
data = GirFFI::SizedArray.from :guint8, arr.size, arr
|
41
41
|
wrap Lib.g_bytes_new data.to_ptr, data.size
|
42
42
|
end
|
@@ -2,13 +2,13 @@ module GLib
|
|
2
2
|
# Common methods for container classes: Array, PtrArray, List, SList and
|
3
3
|
# HashTable.
|
4
4
|
module ContainerClassMethods
|
5
|
-
def wrap
|
5
|
+
def wrap(typespec, ptr)
|
6
6
|
super(ptr).tap do |container|
|
7
7
|
container.reset_typespec typespec if container
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
def from
|
11
|
+
def from(typespec = :void, it)
|
12
12
|
case it
|
13
13
|
when nil
|
14
14
|
nil
|
data/lib/ffi-glib/error.rb
CHANGED
@@ -5,11 +5,11 @@ module GLib
|
|
5
5
|
class Error
|
6
6
|
GIR_FFI_DOMAIN = GLib.quark_from_string('gir_ffi')
|
7
7
|
|
8
|
-
def self.from_exception
|
8
|
+
def self.from_exception(ex)
|
9
9
|
new_literal GIR_FFI_DOMAIN, 0, ex.message
|
10
10
|
end
|
11
11
|
|
12
|
-
def self.from
|
12
|
+
def self.from(it)
|
13
13
|
from_exception it
|
14
14
|
end
|
15
15
|
end
|
data/lib/ffi-glib/hash_table.rb
CHANGED
@@ -13,13 +13,13 @@ module GLib
|
|
13
13
|
|
14
14
|
class << self; remove_method :new; end
|
15
15
|
|
16
|
-
def self.new
|
16
|
+
def self.new(keytype, valtype)
|
17
17
|
wrap [keytype, valtype], Lib.g_hash_table_new(
|
18
18
|
hash_function_for(keytype), equality_function_for(keytype))
|
19
19
|
end
|
20
20
|
|
21
21
|
# @api private
|
22
|
-
def self.from_enumerable
|
22
|
+
def self.from_enumerable(typespec, hash)
|
23
23
|
ghash = new(*typespec)
|
24
24
|
hash.each do |key, val|
|
25
25
|
ghash.insert key, val
|
@@ -28,7 +28,7 @@ module GLib
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# @api private
|
31
|
-
def self.hash_function_for
|
31
|
+
def self.hash_function_for(keytype)
|
32
32
|
case keytype
|
33
33
|
when :utf8
|
34
34
|
FFI::Function.new(:uint,
|
@@ -38,7 +38,7 @@ module GLib
|
|
38
38
|
end
|
39
39
|
|
40
40
|
# @api private
|
41
|
-
def self.equality_function_for
|
41
|
+
def self.equality_function_for(keytype)
|
42
42
|
case keytype
|
43
43
|
when :utf8
|
44
44
|
FFI::Function.new(:int,
|
@@ -48,17 +48,17 @@ module GLib
|
|
48
48
|
end
|
49
49
|
|
50
50
|
# @api private
|
51
|
-
def self.find_support_function
|
51
|
+
def self.find_support_function(name)
|
52
52
|
lib = ::GLib::Lib.ffi_libraries.first
|
53
53
|
lib.find_function(name)
|
54
54
|
end
|
55
55
|
|
56
56
|
def each
|
57
|
-
prc = proc
|
57
|
+
prc = proc do|keyptr, valptr, _userdata|
|
58
58
|
key = GirFFI::ArgHelper.cast_from_pointer key_type, keyptr
|
59
59
|
val = GirFFI::ArgHelper.cast_from_pointer value_type, valptr
|
60
60
|
yield key, val
|
61
|
-
|
61
|
+
end
|
62
62
|
callback = GLib::HFunc.from prc
|
63
63
|
::GLib::Lib.g_hash_table_foreach to_ptr, callback, nil
|
64
64
|
end
|
@@ -68,14 +68,14 @@ module GLib
|
|
68
68
|
end
|
69
69
|
|
70
70
|
# @override
|
71
|
-
def insert
|
71
|
+
def insert(key, value)
|
72
72
|
keyptr = GirFFI::InPointer.from key_type, key
|
73
73
|
valptr = GirFFI::InPointer.from value_type, value
|
74
74
|
::GLib::Lib.g_hash_table_insert to_ptr, keyptr, valptr
|
75
75
|
end
|
76
76
|
|
77
77
|
# @api private
|
78
|
-
def reset_typespec
|
78
|
+
def reset_typespec(typespec)
|
79
79
|
@key_type, @value_type = *typespec
|
80
80
|
self
|
81
81
|
end
|
data/lib/ffi-glib/iconv.rb
CHANGED
@@ -3,7 +3,7 @@ GLib.load_class :IConv
|
|
3
3
|
module GLib
|
4
4
|
# Overrides for IConv
|
5
5
|
class IConv
|
6
|
-
def self.open
|
6
|
+
def self.open(to_codeset, from_codeset)
|
7
7
|
to_ptr = GirFFI::InPointer.from(:utf8, to_codeset)
|
8
8
|
from_ptr = GirFFI::InPointer.from(:utf8, from_codeset)
|
9
9
|
result_ptr = Lib.g_iconv_open(to_ptr, from_ptr)
|
data/lib/ffi-glib/list.rb
CHANGED
@@ -7,11 +7,11 @@ module GLib
|
|
7
7
|
class List
|
8
8
|
include ListMethods
|
9
9
|
|
10
|
-
def self.from_enumerable
|
10
|
+
def self.from_enumerable(type, arr)
|
11
11
|
arr.reduce(new type) { |lst, val| lst.append val }
|
12
12
|
end
|
13
13
|
|
14
|
-
def append
|
14
|
+
def append(data)
|
15
15
|
self.class.wrap(element_type,
|
16
16
|
Lib.g_list_append(self, element_ptr_for(data)))
|
17
17
|
end
|
@@ -6,7 +6,7 @@ module GLib
|
|
6
6
|
include Enumerable
|
7
7
|
attr_reader :element_type
|
8
8
|
|
9
|
-
def self.included
|
9
|
+
def self.included(base)
|
10
10
|
# Override default field accessors.
|
11
11
|
replace_method base, :next, :tail
|
12
12
|
replace_method base, :data, :head
|
@@ -17,7 +17,7 @@ module GLib
|
|
17
17
|
base.extend ContainerClassMethods
|
18
18
|
end
|
19
19
|
|
20
|
-
def self.replace_method
|
20
|
+
def self.replace_method(base, old, new)
|
21
21
|
base.class_eval do
|
22
22
|
remove_method old
|
23
23
|
alias_method old, new
|
@@ -39,12 +39,12 @@ module GLib
|
|
39
39
|
GirFFI::ArgHelper.cast_from_pointer(element_type, @struct[:data])
|
40
40
|
end
|
41
41
|
|
42
|
-
def reset_typespec
|
42
|
+
def reset_typespec(typespec)
|
43
43
|
@element_type = typespec
|
44
44
|
self
|
45
45
|
end
|
46
46
|
|
47
|
-
def ==
|
47
|
+
def ==(other)
|
48
48
|
to_a == other.to_a
|
49
49
|
end
|
50
50
|
|
@@ -61,14 +61,15 @@ module GLib
|
|
61
61
|
element
|
62
62
|
end
|
63
63
|
|
64
|
-
def element_ptr_for
|
64
|
+
def element_ptr_for(data)
|
65
65
|
GirFFI::InPointer.from(element_type, data)
|
66
66
|
end
|
67
67
|
|
68
68
|
# Common class methods for List and SList
|
69
69
|
module ListClassMethods
|
70
|
-
|
71
|
-
|
70
|
+
# TODO: Make this behave more like a real .new method
|
71
|
+
def new(type)
|
72
|
+
allocate.tap do |it|
|
72
73
|
struct = self::Struct.new(FFI::Pointer.new(0))
|
73
74
|
it.instance_variable_set :@struct, struct
|
74
75
|
it.instance_variable_set :@element_type, type
|
data/lib/ffi-glib/main_loop.rb
CHANGED
data/lib/ffi-glib/ptr_array.rb
CHANGED
@@ -21,29 +21,29 @@ module GLib
|
|
21
21
|
remove_method :add if method_defined? :add
|
22
22
|
end
|
23
23
|
|
24
|
-
def self.new
|
24
|
+
def self.new(type)
|
25
25
|
wrap(type, Lib.g_ptr_array_new)
|
26
26
|
end
|
27
27
|
|
28
|
-
def self.from_enumerable
|
28
|
+
def self.from_enumerable(type, it)
|
29
29
|
new(type).tap { |arr| arr.add_array it }
|
30
30
|
end
|
31
31
|
|
32
|
-
def self.add
|
32
|
+
def self.add(array, data)
|
33
33
|
array.add data
|
34
34
|
end
|
35
35
|
|
36
|
-
def reset_typespec
|
36
|
+
def reset_typespec(typespec)
|
37
37
|
@element_type = typespec
|
38
38
|
self
|
39
39
|
end
|
40
40
|
|
41
|
-
def add
|
41
|
+
def add(data)
|
42
42
|
ptr = GirFFI::InPointer.from element_type, data
|
43
43
|
Lib.g_ptr_array_add self, ptr
|
44
44
|
end
|
45
45
|
|
46
|
-
def add_array
|
46
|
+
def add_array(ary)
|
47
47
|
ary.each { |item| add item }
|
48
48
|
end
|
49
49
|
|
@@ -65,7 +65,7 @@ module GLib
|
|
65
65
|
@struct[:len]
|
66
66
|
end
|
67
67
|
|
68
|
-
def ==
|
68
|
+
def ==(other)
|
69
69
|
to_a == other.to_a
|
70
70
|
end
|
71
71
|
end
|
data/lib/ffi-glib/s_list.rb
CHANGED
@@ -7,11 +7,11 @@ module GLib
|
|
7
7
|
class SList
|
8
8
|
include ListMethods
|
9
9
|
|
10
|
-
def self.from_enumerable
|
10
|
+
def self.from_enumerable(type, arr)
|
11
11
|
arr.reverse.reduce(new type) { |lst, val| lst.prepend val }
|
12
12
|
end
|
13
13
|
|
14
|
-
def prepend
|
14
|
+
def prepend(data)
|
15
15
|
self.class.wrap(element_type,
|
16
16
|
Lib.g_slist_prepend(self, element_ptr_for(data)))
|
17
17
|
end
|
data/lib/ffi-glib/strv.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module GLib
|
2
2
|
# Extra methods for GLib::Strv. The bulk is defined in `gir_ffi-base/glib/strv.rb`
|
3
3
|
class Strv
|
4
|
-
def ==
|
4
|
+
def ==(other)
|
5
5
|
to_a == other.to_a
|
6
6
|
end
|
7
7
|
|
8
|
-
def self.from
|
8
|
+
def self.from(it)
|
9
9
|
case it
|
10
10
|
when nil
|
11
11
|
nil
|
@@ -18,7 +18,7 @@ module GLib
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
def self.from_enumerable
|
21
|
+
def self.from_enumerable(enum)
|
22
22
|
wrap GirFFI::InPointer.from_array :utf8, enum
|
23
23
|
end
|
24
24
|
end
|
data/lib/ffi-glib/variant.rb
CHANGED
@@ -9,8 +9,15 @@ module GLib
|
|
9
9
|
get_string_without_override.first
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
# Initializing method used in constructors. For Variant, this needs to sink
|
13
|
+
# the variant's floating reference.
|
14
|
+
#
|
15
|
+
# NOTE: This is very hard to test since it is not possible to get the
|
16
|
+
# variant's ref count directely. However, there is an error when running
|
17
|
+
# the tests on 32-bit systems.
|
18
|
+
def store_pointer(ptr)
|
19
|
+
super
|
20
|
+
::GLib::Lib.g_variant_ref_sink ptr
|
14
21
|
end
|
15
22
|
|
16
23
|
alias_method :get_string_without_override, :get_string
|
data/lib/ffi-gobject.rb
CHANGED
@@ -14,31 +14,31 @@ require 'gir_ffi/builders/user_defined_builder'
|
|
14
14
|
|
15
15
|
# Module representing GLib's GObject namespace.
|
16
16
|
module GObject
|
17
|
-
def self.type_from_instance_pointer
|
17
|
+
def self.type_from_instance_pointer(inst_ptr)
|
18
18
|
return nil if inst_ptr.null?
|
19
19
|
klsptr = inst_ptr.get_pointer 0
|
20
20
|
GirFFI::InOutPointer.new(:GType, klsptr).to_value
|
21
21
|
end
|
22
22
|
|
23
|
-
def self.type_from_instance
|
23
|
+
def self.type_from_instance(instance)
|
24
24
|
type_from_instance_pointer instance.to_ptr
|
25
25
|
end
|
26
26
|
|
27
|
-
def self.object_class_from_instance
|
27
|
+
def self.object_class_from_instance(instance)
|
28
28
|
object_class_from_instance_pointer instance.to_ptr
|
29
29
|
end
|
30
30
|
|
31
|
-
def self.object_class_from_instance_pointer
|
31
|
+
def self.object_class_from_instance_pointer(inst_ptr)
|
32
32
|
return nil if inst_ptr.null?
|
33
33
|
klsptr = inst_ptr.get_pointer 0
|
34
34
|
ObjectClass.wrap klsptr
|
35
35
|
end
|
36
36
|
|
37
|
-
def self.signal_lookup_from_instance
|
37
|
+
def self.signal_lookup_from_instance(signal, object)
|
38
38
|
signal_lookup signal, type_from_instance(object)
|
39
39
|
end
|
40
40
|
|
41
|
-
def self.signal_emit
|
41
|
+
def self.signal_emit(object, detailed_signal, *args)
|
42
42
|
signal, detail = detailed_signal.split('::')
|
43
43
|
signal_id = signal_lookup_from_instance signal, object
|
44
44
|
detail_quark = GLib.quark_from_string(detail)
|
@@ -52,9 +52,9 @@ module GObject
|
|
52
52
|
return_gvalue
|
53
53
|
end
|
54
54
|
|
55
|
-
def self.signal_connect
|
55
|
+
def self.signal_connect(object, detailed_signal, data = nil, after = false, &block)
|
56
56
|
raise ArgumentError, 'Block needed' unless block_given?
|
57
|
-
signal_name,
|
57
|
+
signal_name, = detailed_signal.split('::')
|
58
58
|
sig_info = object.class.find_signal signal_name
|
59
59
|
|
60
60
|
closure = sig_info.wrap_in_closure { |*args| block.call(*args << data) }
|
@@ -62,13 +62,13 @@ module GObject
|
|
62
62
|
signal_connect_closure object, detailed_signal, closure, after
|
63
63
|
end
|
64
64
|
|
65
|
-
def self.signal_connect_after
|
65
|
+
def self.signal_connect_after(object, detailed_signal, data = nil, &block)
|
66
66
|
signal_connect object, detailed_signal, data, true, &block
|
67
67
|
end
|
68
68
|
|
69
69
|
# Smells of :reek:LongParameterList: due to the C interface.
|
70
70
|
# rubocop:disable Metrics/ParameterLists
|
71
|
-
def self.param_spec_int
|
71
|
+
def self.param_spec_int(name, nick, blurb, minimum, maximum, default_value, flags)
|
72
72
|
ptr = Lib.g_param_spec_int(name, nick, blurb, minimum, maximum,
|
73
73
|
default_value, flags)
|
74
74
|
ParamSpecInt.wrap(ptr)
|