gir_ffi 0.11.4 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +5 -5
  2. data/Changelog.md +6 -0
  3. data/Gemfile +1 -6
  4. data/README.md +3 -3
  5. data/Rakefile +2 -0
  6. data/lib/ffi-glib.rb +0 -1
  7. data/lib/ffi-glib/array_methods.rb +1 -1
  8. data/lib/ffi-glib/container_class_methods.rb +1 -1
  9. data/lib/ffi-glib/main_loop.rb +1 -3
  10. data/lib/ffi-gobject/ruby_closure.rb +1 -1
  11. data/lib/ffi-gobject/value.rb +2 -6
  12. data/lib/ffi-gobject_introspection/i_base_info.rb +2 -2
  13. data/lib/gir_ffi/arg_helper.rb +1 -3
  14. data/lib/gir_ffi/builders/argument_builder.rb +3 -5
  15. data/lib/gir_ffi/builders/callback_argument_builder.rb +1 -1
  16. data/lib/gir_ffi/builders/enum_builder.rb +1 -1
  17. data/lib/gir_ffi/builders/initializer_return_value_builder.rb +1 -3
  18. data/lib/gir_ffi/builders/object_builder.rb +4 -4
  19. data/lib/gir_ffi/builders/return_value_builder.rb +1 -1
  20. data/lib/gir_ffi/builders/struct_builder.rb +1 -3
  21. data/lib/gir_ffi/builders/unintrospectable_builder.rb +1 -1
  22. data/lib/gir_ffi/class_base.rb +2 -6
  23. data/lib/gir_ffi/enum_like_base.rb +1 -3
  24. data/lib/gir_ffi/info_ext/i_registered_type_info.rb +1 -1
  25. data/lib/gir_ffi/info_ext/i_type_info.rb +1 -1
  26. data/lib/gir_ffi/info_ext/i_vfunc_info.rb +1 -1
  27. data/lib/gir_ffi/interface_base.rb +1 -3
  28. data/lib/gir_ffi/object_base.rb +1 -1
  29. data/lib/gir_ffi/struct_like_base.rb +6 -3
  30. data/lib/gir_ffi/unintrospectable_boxed_info.rb +1 -1
  31. data/lib/gir_ffi/version.rb +1 -1
  32. data/test/base_test_helper.rb +9 -10
  33. data/test/ffi-gobject/object_test.rb +1 -3
  34. data/test/ffi-gobject/value_test.rb +1 -3
  35. data/test/ffi-gobject_introspection/i_base_info_test.rb +1 -3
  36. data/test/ffi-gobject_introspection/i_repository_test.rb +2 -0
  37. data/test/gir_ffi/arg_helper_test.rb +4 -4
  38. data/test/gir_ffi/boxed_base_test.rb +1 -3
  39. data/test/gir_ffi/builder_test.rb +1 -1
  40. data/test/gir_ffi/builders/field_builder_test.rb +3 -3
  41. data/test/gir_ffi/builders/registered_type_builder_test.rb +1 -3
  42. data/test/gir_ffi/builders/unintrospectable_boxed_builder_test.rb +5 -5
  43. data/test/gir_ffi/builders/unintrospectable_builder_test.rb +2 -2
  44. data/test/gir_ffi/builders/user_defined_builder_test.rb +78 -78
  45. data/test/gir_ffi/class_base_test.rb +7 -7
  46. data/test/gir_ffi/ffi_ext/pointer_test.rb +2 -2
  47. data/test/gir_ffi/info_ext/i_callable_info_test.rb +2 -2
  48. data/test/gir_ffi/info_ext/i_callback_info_test.rb +2 -2
  49. data/test/gir_ffi/info_ext/i_field_info_test.rb +2 -2
  50. data/test/gir_ffi/info_ext/i_function_info_test.rb +2 -2
  51. data/test/gir_ffi/info_ext/i_signal_info_test.rb +2 -2
  52. data/test/gir_ffi/info_ext/i_type_info_test.rb +5 -5
  53. data/test/gir_ffi/info_ext/i_unresolved_info_test.rb +2 -2
  54. data/test/gir_ffi/info_ext/safe_constant_name_test.rb +2 -2
  55. data/test/gir_ffi/info_ext/safe_function_name_test.rb +2 -2
  56. data/test/gir_ffi/method_stubber_test.rb +2 -1
  57. data/test/gir_ffi/struct_like_base_test.rb +22 -22
  58. data/test/gir_ffi/user_defined_object_info_test.rb +11 -11
  59. data/test/gir_ffi_test_helper.rb +1 -3
  60. data/test/integration/generated_glib_test.rb +0 -6
  61. data/test/integration/generated_gobject_test.rb +1 -1
  62. data/test/integration/generated_regress_test.rb +4 -3
  63. data/test/minitest/stats_plugin.rb +3 -1
  64. metadata +27 -15
  65. data/lib/ffi-glib/iconv.rb +0 -15
  66. data/test/ffi-glib/iconv_test.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a183b776462b97665e2e4422ee403c77189232f0
4
- data.tar.gz: 0e803082509b39db6946310f232b5b7dd5ccdee6
2
+ SHA256:
3
+ metadata.gz: 878b55819cccfb1e47cee4e9e7c32f82f10fe6047a354f769099248a7f25ca50
4
+ data.tar.gz: 7324795f3e9ef0427638b6b2cb3ed67a6a2a60daa9d56483173ec11a2198f3a7
5
5
  SHA512:
6
- metadata.gz: 233f733b08504cbc8282d2f2a0fc68caf65e3e648dcc9b0c912c816f83574c38c1e287a1c561db4a11195980243f62024a6a0588376a6f7b0311afa12481b350
7
- data.tar.gz: a4d1c9f718083cbe4932385aa60196ac3bbe870403de227d1cd43914908afb836c42191f3e63ee66021c6da43e07cb432ed6f8d3e241ff95d70b05b818e08fec
6
+ metadata.gz: e28e7c3a60c4957747a808edde2deb2b649b49e832206a32dd5ef655edcbe629081fd89b2cc442811f47e18fefbb0e24d825ef76b9b56b555f3f31afdd2a57ae
7
+ data.tar.gz: aef306323a901033df3e1359318f52f44943a77100a03c20bbbc8e35b99389eb0fe3462ec01fd90c1c671c82a5b26136ed45876aeee7b482d05e329100ec8474
data/Changelog.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.12.0 / 2018-03-024
4
+
5
+ * Drop support for GLib::IConv, which is no longer introspectable in glib 2.56.
6
+ * Drop support for Ruby 2.1 and 2.2
7
+ * Add support for Ruby 2.5
8
+
3
9
  ## 0.11.4 / 2017-09-19
4
10
 
5
11
  * Support glib 2.54 and gobject-introspection 1.54
data/Gemfile CHANGED
@@ -6,10 +6,5 @@ source 'https://rubygems.org'
6
6
  gemspec
7
7
 
8
8
  if ENV['CI']
9
- if ENV['TRAVIS_RUBY_VERSION'] == '2.2'
10
- gem 'coveralls', group: :development
11
- end
12
- else
13
- gem 'pry', '~> 0.10.4', group: :local_development
14
- gem 'simplecov', '~> 0.15.0', group: :local_development, platform: :mri
9
+ gem 'coveralls', group: :development if ENV['TRAVIS_RUBY_VERSION'] == '2.4'
15
10
  end
data/README.md CHANGED
@@ -9,10 +9,10 @@ Ruby bindings for GNOME using the GObject Introspection Repository.
9
9
  ## Status
10
10
 
11
11
  [![Gem Version](https://badge.fury.io/rb/gir_ffi.svg)](http://badge.fury.io/rb/gir_ffi)
12
- [![Dependency Status](https://gemnasium.com/mvz/gir_ffi.svg)](https://gemnasium.com/mvz/gir_ffi)
12
+ [![Depfu](https://badges.depfu.com/badges/d5a8e9bffd2462a7ab4921d2f7e6fc48/overview.svg)](https://depfu.com/github/mvz/gir_ffi)
13
13
  [![Build Status](https://travis-ci.org/mvz/gir_ffi.svg?branch=master)](https://travis-ci.org/mvz/gir_ffi)
14
14
  [![Code Climate](https://codeclimate.com/github/mvz/gir_ffi/badges/gpa.svg)](https://codeclimate.com/github/mvz/gir_ffi)
15
- [![Coverage Status](https://coveralls.io/repos/mvz/gir_ffi/badge.svg?branch=master&service=github)](https://coveralls.io/github/mvz/gir_ffi?branch=master)
15
+ [![Coverage Status](https://coveralls.io/repos/github/mvz/gir_ffi/badge.svg?branch=master)](https://coveralls.io/github/mvz/gir_ffi?branch=master)
16
16
  [![Documentation Status](https://inch-ci.org/github/mvz/gir_ffi.svg?branch=master)](https://inch-ci.org/github/mvz/gir_ffi/branch/master)
17
17
 
18
18
  ## Features
@@ -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 tested on CRuby 2.1, 2.2, 2.3 and 2.4, JRuby 9.1, and on Rubinius 3.
56
+ GirFFI is supported on CRuby 2.3, 2.4 and 2.5, and JRuby 9.1.
57
57
 
58
58
  You will also need gobject-introspection installed with some
59
59
  introspection data.
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake/clean'
2
4
  require 'bundler/gem_tasks'
3
5
 
data/lib/ffi-glib.rb CHANGED
@@ -14,7 +14,6 @@ require 'ffi-glib/bytes'
14
14
  require 'ffi-glib/destroy_notify'
15
15
  require 'ffi-glib/error'
16
16
  require 'ffi-glib/hash_table'
17
- require 'ffi-glib/iconv'
18
17
  require 'ffi-glib/list'
19
18
  require 'ffi-glib/main_loop'
20
19
  require 'ffi-glib/ptr_array'
@@ -5,7 +5,7 @@ module GLib
5
5
  module ArrayMethods
6
6
  # Re-implementation of the g_array_index and g_ptr_array_index macros
7
7
  def index(idx)
8
- if idx >= length || idx < 0
8
+ unless (0...length).cover? idx
9
9
  raise IndexError, "Index #{idx} outside of bounds 0..#{length - 1}"
10
10
  end
11
11
  ptr = GirFFI::InOutPointer.new element_type, data_ptr + idx * element_size
@@ -18,7 +18,7 @@ module GLib
18
18
  end
19
19
 
20
20
  super(ptr).tap do |container|
21
- container.reset_typespec typespec if container
21
+ container&.reset_typespec typespec
22
22
  end
23
23
  end
24
24
 
@@ -40,9 +40,7 @@ module GLib
40
40
  setup_instance_method :run
41
41
 
42
42
  def run_with_thread_enabler
43
- if RUBY_ENGINE == 'ruby'
44
- ThreadEnabler.instance.setup_idle_handler
45
- end
43
+ ThreadEnabler.instance.setup_idle_handler if RUBY_ENGINE == 'ruby'
46
44
  RUNNING_LOOPS << self
47
45
  result = run_without_thread_enabler
48
46
  ex = EXCEPTIONS.shift
@@ -36,7 +36,7 @@ module GObject
36
36
 
37
37
  result = rclosure.invoke_block(*args)
38
38
 
39
- return_value.set_value(result) if return_value
39
+ return_value&.set_value(result)
40
40
  end
41
41
 
42
42
  # @api private
@@ -22,9 +22,7 @@ module GObject
22
22
  proc do
23
23
  if struct.owned?
24
24
  ptr = struct.to_ptr
25
- unless struct[:g_type] == TYPE_INVALID
26
- Lib.g_value_unset ptr
27
- end
25
+ Lib.g_value_unset ptr unless struct[:g_type] == TYPE_INVALID
28
26
  GObject.boxed_free gtype, ptr
29
27
  end
30
28
  end
@@ -141,9 +139,7 @@ module GObject
141
139
  }.freeze
142
140
 
143
141
  def init_for_ruby_value(val)
144
- if val.class.respond_to? :gtype
145
- return init val.class.gtype
146
- end
142
+ return init val.class.gtype if val.class.respond_to? :gtype
147
143
  CLASS_TO_GTYPE_MAP.each do |klass, type|
148
144
  return init type if val.is_a? klass
149
145
  end
@@ -40,7 +40,7 @@ module GObjectIntrospection
40
40
  method = method.to_s
41
41
  single ||= method.to_s[0..-2]
42
42
  count = method.sub(/^(get_)?/, '\\1n_')
43
- class_eval <<-CODE
43
+ class_eval <<-CODE, __FILE__, __LINE__ + 1
44
44
  def #{method}
45
45
  (0..(#{count} - 1)).map do |i|
46
46
  #{single} i
@@ -70,7 +70,7 @@ module GObjectIntrospection
70
70
  single = method.sub(/^find_/, '')
71
71
  counter ||= "n_#{single}s"
72
72
  fetcher ||= single
73
- class_eval <<-CODE
73
+ class_eval <<-CODE, __FILE__, __LINE__ + 1
74
74
  def #{method}(name)
75
75
  name = name.to_s
76
76
  #{counter}.times do |i|
@@ -17,9 +17,7 @@ module GirFFI
17
17
  end
18
18
 
19
19
  def self.check_fixed_array_size(size, arr, name)
20
- unless arr.size.equal? size
21
- raise ArgumentError, "#{name} should have size #{size}"
22
- end
20
+ raise ArgumentError, "#{name} should have size #{size}" unless arr.size.equal? size
23
21
  end
24
22
 
25
23
  # NOTE: Only used in List, SList and HashTable classes.
@@ -84,9 +84,7 @@ module GirFFI
84
84
  end
85
85
 
86
86
  def output_value
87
- if caller_allocated_object? && gvalue?
88
- return "#{call_argument_name}.get_value"
89
- end
87
+ return "#{call_argument_name}.get_value" if caller_allocated_object? && gvalue?
90
88
  base = pointer_to_value_method_call call_argument_name, type_spec
91
89
  if needs_out_conversion?
92
90
  outgoing_convertor(base).conversion
@@ -127,7 +125,7 @@ module GirFFI
127
125
  end
128
126
 
129
127
  def length_argument_name
130
- length_arg && length_arg.post_converted_name
128
+ length_arg&.post_converted_name
131
129
  end
132
130
 
133
131
  def needs_size_check?
@@ -188,7 +186,7 @@ module GirFFI
188
186
  @arginfo.caller_allocates?
189
187
  end
190
188
 
191
- DESTROY_NOTIFIER = 'GLib::DestroyNotify.default'.freeze
189
+ DESTROY_NOTIFIER = 'GLib::DestroyNotify.default'
192
190
 
193
191
  def ingoing_convertor
194
192
  if skipped_in?
@@ -170,7 +170,7 @@ module GirFFI
170
170
  end
171
171
 
172
172
  def length_argument_name
173
- length_arg && length_arg.pre_converted_name
173
+ length_arg&.pre_converted_name
174
174
  end
175
175
  end
176
176
  end
@@ -41,7 +41,7 @@ module GirFFI
41
41
  end
42
42
 
43
43
  def setup_inspect
44
- klass.instance_eval <<-RUBY
44
+ klass.instance_eval <<-RUBY, __FILE__, __LINE__ + 1
45
45
  def self.inspect
46
46
  "#{@namespace}::#{@classname}"
47
47
  end
@@ -9,9 +9,7 @@ module GirFFI
9
9
  def post_conversion
10
10
  result = []
11
11
  result << "store_pointer(#{capture_variable_name})"
12
- if specialized_type_tag == :struct
13
- result << '@struct.owned = true'
14
- end
12
+ result << '@struct.owned = true' if specialized_type_tag == :struct
15
13
  result
16
14
  end
17
15
  end
@@ -121,24 +121,24 @@ module GirFFI
121
121
 
122
122
  def define_vfunc_invoker(vfunc_name, invoker_name)
123
123
  return if vfunc_name == invoker_name
124
- klass.class_eval "
124
+ klass.class_eval <<-DEF, __FILE__, __LINE__ + 1
125
125
  def #{vfunc_name} *args, &block
126
126
  #{invoker_name}(*args, &block)
127
127
  end
128
- "
128
+ DEF
129
129
  end
130
130
 
131
131
  def provide_initializer
132
132
  return if info.find_method 'new'
133
133
 
134
134
  if info.abstract?
135
- klass.class_eval <<-RUBY
135
+ klass.class_eval <<-RUBY, __FILE__, __LINE__ + 1
136
136
  def initialize(*)
137
137
  raise NoMethodError
138
138
  end
139
139
  RUBY
140
140
  else
141
- klass.class_eval <<-RUBY
141
+ klass.class_eval <<-RUBY, __FILE__, __LINE__ + 1
142
142
  def initialize(properties = {})
143
143
  base_initialize(properties)
144
144
  end
@@ -39,7 +39,7 @@ module GirFFI
39
39
  end
40
40
 
41
41
  def length_argument_name
42
- length_arg && length_arg.post_converted_name
42
+ length_arg&.post_converted_name
43
43
  end
44
44
  end
45
45
  end
@@ -23,9 +23,7 @@ module GirFFI
23
23
  return type.tag_or_class if type.tag == :interface
24
24
  end
25
25
 
26
- if GObject.type_fundamental(info.gtype) == GObject::TYPE_BOXED
27
- return BoxedBase
28
- end
26
+ return BoxedBase if GObject.type_fundamental(info.gtype) == GObject::TYPE_BOXED
29
27
 
30
28
  StructBase
31
29
  end
@@ -27,7 +27,7 @@ module GirFFI
27
27
  info = super
28
28
  return info if info
29
29
  signal_id = GObject.signal_lookup signal_name, target_gtype
30
- return UnintrospectableSignalInfo.new(signal_id) if signal_id > 0
30
+ return UnintrospectableSignalInfo.new(signal_id) unless signal_id.zero?
31
31
  end
32
32
  end
33
33
  end
@@ -19,9 +19,7 @@ module GirFFI
19
19
  def setup_and_call(method, arguments, &block)
20
20
  method_name = self.class.try_in_ancestors(:setup_instance_method, method.to_s)
21
21
 
22
- unless method_name
23
- raise NoMethodError, "undefined method `#{method}' for #{self}"
24
- end
22
+ raise NoMethodError, "undefined method `#{method}' for #{self}" unless method_name
25
23
 
26
24
  send method_name, *arguments, &block
27
25
  end
@@ -35,9 +33,7 @@ module GirFFI
35
33
  def self.setup_and_call(method, arguments, &block)
36
34
  method_name = try_in_ancestors(:setup_method, method.to_s)
37
35
 
38
- unless method_name
39
- raise NoMethodError, "undefined method `#{method}' for #{self}"
40
- end
36
+ raise NoMethodError, "undefined method `#{method}' for #{self}" unless method_name
41
37
 
42
38
  send method_name, *arguments, &block
43
39
  end
@@ -31,9 +31,7 @@ module GirFFI
31
31
  def setup_and_call(method, arguments, &block)
32
32
  result = setup_method method.to_s
33
33
 
34
- unless result
35
- raise "Unable to set up method #{method} in #{self}"
36
- end
34
+ raise "Unable to set up method #{method} in #{self}" unless result
37
35
 
38
36
  send method, *arguments, &block
39
37
  end
@@ -16,7 +16,7 @@ module GirFFI
16
16
 
17
17
  def find_instance_method(method)
18
18
  info = find_method method
19
- return info if info && info.method?
19
+ return info if info&.method?
20
20
  end
21
21
 
22
22
  def find_method(_method)
@@ -194,7 +194,7 @@ module GirFFI
194
194
  end
195
195
  end
196
196
 
197
- GOBJECT_VALUE_NAME = 'GObject::Value'.freeze
197
+ GOBJECT_VALUE_NAME = 'GObject::Value'
198
198
 
199
199
  def gvalue?
200
200
  argument_class_name == GOBJECT_VALUE_NAME
@@ -16,7 +16,7 @@ module GirFFI
16
16
  end
17
17
 
18
18
  def invoker_name
19
- invoker && invoker.name
19
+ invoker&.name
20
20
  end
21
21
 
22
22
  def has_invoker?
@@ -9,9 +9,7 @@ module GirFFI
9
9
 
10
10
  def setup_and_call(method, arguments, &block)
11
11
  method_name = setup_method method.to_s
12
- unless method_name
13
- raise NoMethodError, "undefined method `#{method}' for #{self}"
14
- end
12
+ raise NoMethodError, "undefined method `#{method}' for #{self}" unless method_name
15
13
  send method_name, *arguments, &block
16
14
  end
17
15
 
@@ -38,7 +38,7 @@ module GirFFI
38
38
  end
39
39
 
40
40
  def self.copy_from(val)
41
- val.ref if val
41
+ val&.ref
42
42
  end
43
43
 
44
44
  #
@@ -38,34 +38,37 @@ module GirFFI
38
38
 
39
39
  # Create an unowned copy of the struct represented by val
40
40
  def copy_from(val)
41
+ return unless val
41
42
  disown copy from(val)
42
43
  end
43
44
 
44
45
  # Wrap an owned copy of the struct represented by val
45
46
  def wrap_copy(val)
47
+ return unless val
46
48
  own copy(val)
47
49
  end
48
50
 
49
51
  # Wrap value and take ownership of it
50
52
  def wrap_own(val)
53
+ return unless val
54
+ return if val.null?
51
55
  own wrap(val)
52
56
  end
53
57
 
54
58
  private
55
59
 
56
60
  def own(val)
57
- val.struct.owned = true if val
61
+ val.struct.owned = true
58
62
  val
59
63
  end
60
64
 
61
65
  def disown(val)
62
- val.struct.owned = nil if val
66
+ val.struct.owned = nil
63
67
  val
64
68
  end
65
69
 
66
70
  # Create a copy of the struct represented by val
67
71
  def copy(val)
68
- return unless val
69
72
  new.tap do |copy|
70
73
  copy_value_to_pointer(val, copy.to_ptr)
71
74
  end
@@ -20,7 +20,7 @@ module GirFFI
20
20
  GObject.type_name g_type
21
21
  end
22
22
 
23
- DEFAULT_BOXED_NAMESPACE = 'GLib'.freeze
23
+ DEFAULT_BOXED_NAMESPACE = 'GLib'
24
24
 
25
25
  def namespace
26
26
  DEFAULT_BOXED_NAMESPACE
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Current GirFFI version
4
4
  module GirFFI
5
- VERSION = '0.11.4'.freeze
5
+ VERSION = '0.12.0'
6
6
  end