gir_ffi 0.7.5 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +17 -1
  3. data/README.md +1 -1
  4. data/Rakefile +0 -7
  5. data/examples/main_loop.rb +12 -0
  6. data/lib/ffi-glib/array.rb +18 -5
  7. data/lib/ffi-glib/array_methods.rb +1 -1
  8. data/lib/ffi-glib/list.rb +1 -1
  9. data/lib/ffi-glib/list_methods.rb +1 -1
  10. data/lib/ffi-glib/main_loop.rb +51 -0
  11. data/lib/ffi-glib/ptr_array.rb +2 -2
  12. data/lib/ffi-glib/s_list.rb +1 -1
  13. data/lib/ffi-glib/variant.rb +3 -3
  14. data/lib/ffi-glib.rb +1 -0
  15. data/lib/ffi-gobject/initially_unowned.rb +1 -1
  16. data/lib/ffi-gobject/object.rb +14 -12
  17. data/lib/ffi-gobject/ruby_closure.rb +3 -2
  18. data/lib/ffi-gobject/value.rb +12 -16
  19. data/lib/ffi-gobject.rb +4 -21
  20. data/lib/ffi-gobject_introspection/i_base_info.rb +3 -3
  21. data/lib/ffi-gobject_introspection/i_interface_info.rb +1 -1
  22. data/lib/ffi-gobject_introspection/i_repository.rb +1 -1
  23. data/lib/ffi-gobject_introspection/lib.rb +1 -1
  24. data/lib/gir_ffi/arg_helper.rb +2 -2
  25. data/lib/gir_ffi/builder.rb +1 -1
  26. data/lib/gir_ffi/builders/argument_builder.rb +19 -17
  27. data/lib/gir_ffi/builders/argument_builder_collection.rb +51 -16
  28. data/lib/gir_ffi/builders/base_argument_builder.rb +20 -10
  29. data/lib/gir_ffi/builders/base_type_builder.rb +6 -5
  30. data/lib/gir_ffi/builders/callback_argument_builder.rb +5 -5
  31. data/lib/gir_ffi/builders/callback_builder.rb +0 -4
  32. data/lib/gir_ffi/builders/callback_return_value_builder.rb +11 -11
  33. data/lib/gir_ffi/builders/constant_builder.rb +2 -4
  34. data/lib/gir_ffi/builders/enum_builder.rb +7 -7
  35. data/lib/gir_ffi/builders/error_argument_builder.rb +16 -4
  36. data/lib/gir_ffi/builders/field_builder.rb +5 -17
  37. data/lib/gir_ffi/builders/function_builder.rb +36 -86
  38. data/lib/gir_ffi/builders/interface_builder.rb +2 -7
  39. data/lib/gir_ffi/builders/mapping_method_builder.rb +42 -33
  40. data/lib/gir_ffi/builders/marshalling_method_builder.rb +44 -33
  41. data/lib/gir_ffi/builders/method_template.rb +81 -0
  42. data/lib/gir_ffi/builders/module_builder.rb +5 -5
  43. data/lib/gir_ffi/builders/object_builder.rb +44 -25
  44. data/lib/gir_ffi/builders/property_builder.rb +6 -2
  45. data/lib/gir_ffi/builders/registered_type_builder.rb +1 -5
  46. data/lib/gir_ffi/builders/return_value_builder.rb +20 -15
  47. data/lib/gir_ffi/builders/signal_closure_builder.rb +3 -6
  48. data/lib/gir_ffi/builders/type_builder.rb +1 -1
  49. data/lib/gir_ffi/builders/unintrospectable_builder.rb +1 -5
  50. data/lib/gir_ffi/builders/user_defined_builder.rb +17 -21
  51. data/lib/gir_ffi/builders/vfunc_builder.rb +3 -6
  52. data/lib/gir_ffi/builders/with_layout.rb +2 -6
  53. data/lib/gir_ffi/callback_base.rb +10 -5
  54. data/lib/gir_ffi/class_base.rb +4 -7
  55. data/lib/gir_ffi/enum_base.rb +1 -1
  56. data/lib/gir_ffi/g_type.rb +21 -19
  57. data/lib/gir_ffi/in_out_pointer.rb +2 -4
  58. data/lib/gir_ffi/in_pointer.rb +9 -8
  59. data/lib/gir_ffi/info_ext/i_field_info.rb +1 -3
  60. data/lib/gir_ffi/info_ext/i_signal_info.rb +4 -4
  61. data/lib/gir_ffi/info_ext/i_type_info.rb +6 -6
  62. data/lib/gir_ffi/module_base.rb +3 -2
  63. data/lib/gir_ffi/object_base.rb +1 -1
  64. data/lib/gir_ffi/struct_base.rb +1 -1
  65. data/lib/gir_ffi/type_base.rb +2 -2
  66. data/lib/gir_ffi/unintrospectable_type_info.rb +2 -0
  67. data/lib/gir_ffi/version.rb +1 -1
  68. data/lib/gir_ffi/zero_terminated.rb +1 -1
  69. data/lib/gir_ffi-base/glib/strv.rb +2 -2
  70. data/lib/gir_ffi.rb +1 -1
  71. data/test/ffi-glib/array_test.rb +28 -0
  72. data/test/ffi-glib/byte_array_test.rb +1 -1
  73. data/test/ffi-glib/bytes_test.rb +1 -1
  74. data/test/ffi-gobject/object_test.rb +11 -1
  75. data/test/ffi-gobject/value_test.rb +12 -1
  76. data/test/ffi-gobject_introspection/i_base_info_test.rb +14 -0
  77. data/test/ffi-gobject_introspection/i_object_info_test.rb +8 -6
  78. data/test/ffi-gobject_introspection/i_registered_type_info_test.rb +24 -0
  79. data/test/ffi-gobject_introspection/i_type_info_test.rb +17 -0
  80. data/test/gir_ffi/builder_test.rb +3 -2
  81. data/test/gir_ffi/builders/argument_builder_test.rb +2 -2
  82. data/test/gir_ffi/builders/function_builder_test.rb +27 -27
  83. data/test/gir_ffi/builders/object_builder_test.rb +10 -0
  84. data/test/gir_ffi/builders/return_value_builder_test.rb +3 -3
  85. data/test/gir_ffi/builders/signal_closure_builder_test.rb +6 -6
  86. data/test/gir_ffi/in_out_pointer_test.rb +0 -2
  87. data/test/gir_ffi/info_ext/i_type_info_test.rb +1 -1
  88. data/test/gir_ffi_test_helper.rb +0 -4
  89. data/test/integration/generated_gimarshallingtests_test.rb +1 -1
  90. data/test/integration/generated_regress_test.rb +2 -2
  91. data/test/integration/idle_loop_test.rb +25 -0
  92. data/test/minitest/stats_plugin.rb +26 -0
  93. metadata +13 -62
  94. data/lib/gir_ffi/builders/null_argument_builder.rb +0 -12
  95. data/lib/gir_ffi/builders/null_builder.rb +0 -12
  96. data/tasks/yard.rake +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 18cf75d3dd4a310371647db4f56ab2bdcf516245
4
- data.tar.gz: d3a5fe4123bdc4ae02e7eae61364e87fa7f01cca
3
+ metadata.gz: 784da223496ff93dd574411f1058071f336aa18e
4
+ data.tar.gz: ffbc7a82e2b710669a74055bf436a8c26d2ed956
5
5
  SHA512:
6
- metadata.gz: 5280cf6c320d6c50cf10bf320c8738ed5c14ae22867ceb8c8de74a31d6a1a6c5990cb572d26772574bac971296547ca333fcd91e051d3e8aaae2165851a2ac0d
7
- data.tar.gz: 4f2d7eb7bb6161c3436388ce09b3948e7e04f428053055eedf4386f264dd7faac6c91d6b198abf52b471319b3a0cd6be6e905a68ee3076a21ac03a99731ea0db
6
+ metadata.gz: b9a5bbd317a59c9cad7840e318e9a03e12413a130e259677216fc7fe6ad9ab5592017bdff9904ec15da9aa65a8f5dbf72b3d74f33f477c3c698309bce3ff4649
7
+ data.tar.gz: 1c7ec6f5c809e141c6f5338c742a1a3042cdbc18645dfc3631f838fe090b36fa12822b60eddf875d58707f78e2ad9e5e16c28a9ef7843e41f16a7902a4e882a3
data/Changelog.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.6 / 2014-08-22
4
+
5
+ * Work around respond_to? behavior in JRuby 1.6.13
6
+ * Deprecate setup_class in favor of load_class
7
+ * Support GValue containing GArray
8
+ * Provide constant TYPE_BYTE_ARRAY
9
+ * Don't recurse looking for signals and properties
10
+ * Clean up generated code:
11
+ * Avoid use of an ignored dummy argument
12
+ * Clean up trailing whitespace
13
+ * Drop support for Ruby 1.9.2
14
+ * Allow data argument for GObject::Object#signal_connect
15
+ * Let Ruby threads run during GLib's main loop
16
+ * Make all dependencies versioned
17
+ * Various refactoring & code cleanup
18
+
3
19
  ## 0.7.5 / 2014-06-22
4
20
 
5
21
  * Use closures as signal handlers, rather than callbacks
@@ -58,7 +74,7 @@
58
74
  * Register defined properties in a subclass
59
75
  * Support setting virtual function implementations in a subclass
60
76
  * Support adding an interface to a subclass
61
- * Support implementing an interface's virtual functions in a subclass
77
+ * Support implementing an interface's virtual functions in a subclass
62
78
  * Use FFI's DataConvertor system to handle enums and callbacks
63
79
  * Stop using deprecated GValueArray to construct argument array for signal_emit
64
80
  * Make ITypeInfo#g_type return correct value for c arrays
data/README.md CHANGED
@@ -45,7 +45,7 @@ Ruby bindings for GNOME using the GObject Introspection Repository.
45
45
 
46
46
  ## Requirements
47
47
 
48
- GirFFI should work on MRI 1.9, 2.0, and 2.1, JRuby in 1.9 mode, and on
48
+ GirFFI should work on MRI 1.9.3, 2.0, and 2.1, JRuby in 1.9 or 2.0 mode, and on
49
49
  Rubinius.
50
50
 
51
51
  You will also need gobject-introspection installed with some
data/Rakefile CHANGED
@@ -9,14 +9,7 @@ end
9
9
 
10
10
  MyGemHelper.install_tasks
11
11
 
12
- begin
13
- require 'repl_rake'
14
- ReplRake.setup
15
- rescue LoadError
16
- end
17
-
18
12
  load 'tasks/test.rake'
19
13
  load 'tasks/valgrind.rake'
20
- load 'tasks/yard.rake'
21
14
 
22
15
  task :default => 'test:all'
@@ -0,0 +1,12 @@
1
+ require 'gir_ffi'
2
+
3
+ main_loop = GLib::MainLoop.new nil, false
4
+
5
+ Signal.trap("INT") do
6
+ if main_loop.is_running
7
+ main_loop.quit
8
+ end
9
+ exit
10
+ end
11
+
12
+ main_loop.run
@@ -44,20 +44,24 @@ module GLib
44
44
  Lib.g_array_get_element_size self
45
45
  end
46
46
 
47
- alias element_size get_element_size
47
+ alias_method :element_size, :get_element_size
48
48
 
49
49
  def == other
50
50
  to_a == other.to_a
51
51
  end
52
52
 
53
- def reset_typespec typespec
54
- @element_type = typespec
55
- check_element_size_match
53
+ def reset_typespec typespec = nil
54
+ if typespec
55
+ @element_type = typespec
56
+ check_element_size_match
57
+ else
58
+ @element_type = guess_element_type
59
+ end
56
60
  self
57
61
  end
58
62
 
59
63
  def self.from_enumerable elmtype, it
60
- new(elmtype).tap {|arr| arr.append_vals it }
64
+ new(elmtype).tap { |arr| arr.append_vals it }
61
65
  end
62
66
 
63
67
  private
@@ -76,5 +80,14 @@ module GLib
76
80
  warn "WARNING: Element sizes do not match"
77
81
  end
78
82
  end
83
+
84
+ def guess_element_type
85
+ case get_element_size
86
+ when 1 then :uint8
87
+ when 2 then :uint16
88
+ when 4 then :uint32
89
+ when 8 then :uint64
90
+ end
91
+ end
79
92
  end
80
93
  end
@@ -3,7 +3,7 @@ module GLib
3
3
  module ArrayMethods
4
4
  # Re-implementation of the g_array_index and g_ptr_array_index macros
5
5
  def index idx
6
- if idx >= length or idx < 0
6
+ if idx >= length || idx < 0
7
7
  raise IndexError, "Index #{idx} outside of bounds 0..#{length - 1}"
8
8
  end
9
9
  ptr = GirFFI::InOutPointer.new element_type, data_ptr + idx * element_size
data/lib/ffi-glib/list.rb CHANGED
@@ -8,7 +8,7 @@ module GLib
8
8
  include ListMethods
9
9
 
10
10
  def self.from_enumerable type, arr
11
- arr.inject(new type) { |lst, val| lst.append val }
11
+ arr.reduce(new type) { |lst, val| lst.append val }
12
12
  end
13
13
 
14
14
  def append data
@@ -55,7 +55,7 @@ module GLib
55
55
  end
56
56
 
57
57
  def next_element
58
- return if !@current
58
+ return unless @current
59
59
  element = @current.head
60
60
  @current = @current.tail
61
61
  element
@@ -0,0 +1,51 @@
1
+ require 'singleton'
2
+
3
+ GLib.load_class :MainLoop
4
+
5
+ module GLib
6
+ # Overrides for GMainLoop, GLib's event loop
7
+ class MainLoop
8
+ # Class encepsulationg logic for running an idle handler to make Ruby code
9
+ # run during GLib's event loop.
10
+ class ThreadEnabler
11
+ include Singleton
12
+
13
+ FRAMERATE = 25
14
+ DEFAULT_TIMEOUT = 1000 / FRAMERATE
15
+
16
+ def initialize timeout = DEFAULT_TIMEOUT
17
+ @timeout = timeout
18
+ end
19
+
20
+ def setup_idle_handler
21
+ @handler_id ||= GLib.timeout_add(GLib::PRIORITY_DEFAULT,
22
+ @timeout, handler_proc,
23
+ nil, nil)
24
+ end
25
+
26
+ private
27
+
28
+ def handler_proc
29
+ proc do
30
+ Thread.pass
31
+ true
32
+ end
33
+ end
34
+ end
35
+
36
+ setup_instance_method "run_with_thread_enabler"
37
+
38
+ def run_with_thread_enabler
39
+ case RUBY_ENGINE
40
+ when 'jruby'
41
+ when 'rbx'
42
+ else # 'ruby' most likely
43
+ ThreadEnabler.instance.setup_idle_handler
44
+ end
45
+ run_without_thread_enabler
46
+ end
47
+
48
+ alias_method :run_without_thread_enabler, :run
49
+ alias_method :run, :run_with_thread_enabler
50
+ end
51
+ end
@@ -26,7 +26,7 @@ module GLib
26
26
  end
27
27
 
28
28
  def self.from_enumerable type, it
29
- new(type).tap {|arr| arr.add_array it}
29
+ new(type).tap { |arr| arr.add_array it }
30
30
  end
31
31
 
32
32
  def self.add array, data
@@ -44,7 +44,7 @@ module GLib
44
44
  end
45
45
 
46
46
  def add_array ary
47
- ary.each {|item| add item}
47
+ ary.each { |item| add item }
48
48
  end
49
49
 
50
50
  def data_ptr
@@ -8,7 +8,7 @@ module GLib
8
8
  include ListMethods
9
9
 
10
10
  def self.from_enumerable type, arr
11
- arr.reverse.inject(new type) { |lst, val| lst.prepend val }
11
+ arr.reverse.reduce(new type) { |lst, val| lst.prepend val }
12
12
  end
13
13
 
14
14
  def prepend data
@@ -10,10 +10,10 @@ module GLib
10
10
  end
11
11
 
12
12
  def self.constructor_wrap ptr
13
- super.tap {|variant| variant.ref }
13
+ super.tap { |variant| variant.ref }
14
14
  end
15
15
 
16
- alias get_string_without_override get_string
17
- alias get_string get_string_with_override
16
+ alias_method :get_string_without_override, :get_string
17
+ alias_method :get_string, :get_string_with_override
18
18
  end
19
19
  end
data/lib/ffi-glib.rb CHANGED
@@ -10,6 +10,7 @@ require 'ffi-glib/error'
10
10
  require 'ffi-glib/hash_table'
11
11
  require 'ffi-glib/iconv'
12
12
  require 'ffi-glib/list'
13
+ require 'ffi-glib/main_loop'
13
14
  require 'ffi-glib/ptr_array'
14
15
  require 'ffi-glib/s_list'
15
16
  require 'ffi-glib/strv'
@@ -7,7 +7,7 @@ module GObject
7
7
  # Wrapping method used in constructors. For InitiallyUnowned and
8
8
  # descendants, this needs to sink the object's floating reference.
9
9
  def self.constructor_wrap ptr
10
- super.tap {|obj| ::GObject.object_ref_sink obj}
10
+ super.tap { |obj| ::GObject::Lib.g_object_ref_sink obj }
11
11
  end
12
12
  end
13
13
  end
@@ -3,22 +3,21 @@ GObject.load_class :Object
3
3
  module GObject
4
4
  # Overrides for GObject, GObject's generic base class.
5
5
  class Object
6
-
7
6
  setup_method "new"
8
7
 
9
8
  # TODO: Generate accessor methods from GIR at class definition time
10
9
  def method_missing method, *args
11
- if respond_to?("get_#{method}")
12
- return send("get_#{method}", *args)
13
- end
14
- if method.to_s =~ /(.*)=$/ && respond_to?("set_#{$1}")
15
- return send("set_#{$1}", *args)
10
+ getter_name = "get_#{method}"
11
+ return send(getter_name, *args) if respond_to?(getter_name)
12
+ if method.to_s =~ /(.*)=$/
13
+ setter_name = "set_#{Regexp.last_match[1]}"
14
+ return send(setter_name, *args) if respond_to?(setter_name)
16
15
  end
17
16
  super
18
17
  end
19
18
 
20
- def signal_connect event, &block
21
- GObject.signal_connect(self, event, &block)
19
+ def signal_connect event, data = nil, &block
20
+ GObject.signal_connect(self, event, data, &block)
22
21
  end
23
22
 
24
23
  setup_instance_method "get_property"
@@ -62,11 +61,14 @@ module GObject
62
61
  GObject::ObjectClass.wrap(to_ptr.get_pointer 0)
63
62
  end
64
63
 
65
- alias get_property_without_override get_property
66
- alias get_property get_property_with_override
64
+ alias_method :get_property_without_override, :get_property
65
+ alias_method :get_property, :get_property_with_override
66
+
67
+ alias_method :set_property_without_override, :set_property
68
+ alias_method :set_property, :set_property_with_override
67
69
 
68
- alias set_property_without_override set_property
69
- alias set_property set_property_with_override
70
+ setup_instance_method 'is_floating'
71
+ alias_method :floating?, :is_floating
70
72
 
71
73
  private
72
74
 
@@ -32,16 +32,17 @@ module GObject
32
32
 
33
33
  closure = wrap(new_simple(self::Struct.size, nil).to_ptr)
34
34
  closure.block = block
35
- closure.set_marshal Proc.new {|*args| marshaller(*args)}
35
+ closure.set_marshal proc { |*args| marshaller(*args) }
36
36
 
37
37
  closure
38
38
  end
39
39
 
40
40
  def self.marshaller closure, return_value, param_values, _invocation_hint, _marshal_data
41
+ # TODO: Improve by registering RubyClosure as a GObject type
41
42
  rclosure = wrap(closure.to_ptr)
42
43
  param_values ||= []
43
44
 
44
- args = param_values.map {|value| value.get_value }
45
+ args = param_values.map { |value| value.get_value }
45
46
 
46
47
  result = rclosure.invoke_block(*args)
47
48
 
@@ -5,10 +5,7 @@ module GObject
5
5
  class Value
6
6
  # TODO: Give more generic name
7
7
  def set_ruby_value val
8
- if current_gtype == 0
9
- init_for_ruby_value val
10
- end
11
-
8
+ init_for_ruby_value val if current_gtype == 0
12
9
  set_value val
13
10
  end
14
11
 
@@ -35,25 +32,22 @@ module GObject
35
32
  TYPE_VARIANT => [:get_variant, :set_variant]
36
33
  }
37
34
 
38
- def value= val
39
- set_value val
40
- end
41
-
42
35
  def set_value val
43
36
  send set_method, val
44
- self
45
37
  end
46
38
 
39
+ alias_method :value=, :set_value
40
+
47
41
  CLASS_TO_GTYPE_MAP = {
48
- true => TYPE_BOOLEAN,
49
- false => TYPE_BOOLEAN,
42
+ TrueClass => TYPE_BOOLEAN,
43
+ FalseClass => TYPE_BOOLEAN,
50
44
  Integer => TYPE_INT,
51
45
  String => TYPE_STRING
52
46
  }
53
47
 
54
48
  def init_for_ruby_value val
55
49
  CLASS_TO_GTYPE_MAP.each do |klass, type|
56
- if klass === val
50
+ if val.is_a? klass
57
51
  init type
58
52
  return self
59
53
  end
@@ -88,7 +82,7 @@ module GObject
88
82
 
89
83
  # TODO: Give more generic name
90
84
  def self.wrap_ruby_value val
91
- new.set_ruby_value val
85
+ new.tap { |gv| gv.set_ruby_value val }
92
86
  end
93
87
 
94
88
  def self.from val
@@ -104,7 +98,7 @@ module GObject
104
98
 
105
99
  def self.for_g_type g_type
106
100
  return nil if g_type == TYPE_NONE
107
- new.tap {|it| it.init g_type }
101
+ new.tap { |it| it.init g_type }
108
102
  end
109
103
 
110
104
  # TODO: Combine with wrap_ruby_value
@@ -131,7 +125,7 @@ module GObject
131
125
  end
132
126
 
133
127
  def check_type_compatibility val
134
- if !GObject::Value.type_compatible(GObject.type_from_instance(val), current_gtype)
128
+ unless GObject::Value.type_compatible(GObject.type_from_instance(val), current_gtype)
135
129
  raise ArgumentError, "#{val.class} is incompatible with #{current_gtype_name}"
136
130
  end
137
131
  end
@@ -142,6 +136,8 @@ module GObject
142
136
  GLib::Strv.wrap boxed
143
137
  when TYPE_HASH_TABLE
144
138
  GLib::HashTable.wrap [:gpointer, :gpointer], boxed
139
+ when TYPE_ARRAY
140
+ GLib::Array.wrap nil, boxed
145
141
  else
146
142
  current_gtype_class.wrap(boxed) unless boxed.null?
147
143
  end
@@ -157,7 +153,7 @@ module GObject
157
153
 
158
154
  def method_map_entry
159
155
  METHOD_MAP[current_gtype] || METHOD_MAP[current_fundamental_type] ||
160
- fail("No method map entry for #{current_gtype_name}")
156
+ raise("No method map entry for #{current_gtype_name}")
161
157
  end
162
158
  end
163
159
  end
data/lib/ffi-gobject.rb CHANGED
@@ -15,22 +15,6 @@ require 'gir_ffi/builders/user_defined_builder'
15
15
 
16
16
  # Module representing GLib's GObject namespace.
17
17
  module GObject
18
- def self.object_ref obj
19
- Lib.g_object_ref obj.to_ptr
20
- end
21
-
22
- def self.object_ref_sink obj
23
- Lib.g_object_ref_sink obj.to_ptr
24
- end
25
-
26
- def self.object_unref obj
27
- Lib.g_object_unref obj.to_ptr
28
- end
29
-
30
- def self.object_is_floating obj
31
- Lib.g_object_is_floating obj.to_ptr
32
- end
33
-
34
18
  def self.type_from_instance_pointer inst_ptr
35
19
  return nil if inst_ptr.null?
36
20
  klsptr = inst_ptr.get_pointer 0
@@ -70,12 +54,12 @@ module GObject
70
54
  return_gvalue
71
55
  end
72
56
 
73
- def self.signal_connect object, detailed_signal, data=nil, &block
57
+ def self.signal_connect object, detailed_signal, data = nil, &block
74
58
  raise ArgumentError, "Block needed" unless block_given?
75
59
  signal_name, _ = detailed_signal.split('::')
76
60
  sig_info = object.class.find_signal signal_name
77
61
 
78
- closure = sig_info.wrap_in_closure {|*args| block.call(*args << data) }
62
+ closure = sig_info.wrap_in_closure { |*args| block.call(*args << data) }
79
63
 
80
64
  # TODO: Provide _after variant
81
65
  signal_connect_closure object, detailed_signal, closure, false
@@ -96,12 +80,10 @@ module GObject
96
80
 
97
81
  # NOTE: This Lib module is set up in `gir_ffi-base/gobject/lib.rb`.
98
82
  module Lib
99
- attach_function :g_object_ref, [:pointer], :void
100
83
  attach_function :g_object_ref_sink, [:pointer], :void
101
- attach_function :g_object_unref, [:pointer], :void
102
- attach_function :g_object_is_floating, [:pointer], :bool
103
84
 
104
85
  attach_function :g_array_get_type, [], :size_t
86
+ attach_function :g_byte_array_get_type, [], :size_t
105
87
  attach_function :g_hash_table_get_type, [], :size_t
106
88
  attach_function :g_strv_get_type, [], :size_t
107
89
 
@@ -117,6 +99,7 @@ module GObject
117
99
  end
118
100
 
119
101
  TYPE_ARRAY = Lib.g_array_get_type
102
+ TYPE_BYTE_ARRAY = Lib.g_byte_array_get_type
120
103
  TYPE_HASH_TABLE = Lib.g_hash_table_get_type
121
104
  TYPE_STRV = Lib.g_strv_get_type
122
105
  end
@@ -2,7 +2,7 @@ module GObjectIntrospection
2
2
  # Wraps GIBaseInfo struct, the base \type for all info types.
3
3
  # Decendant types will be implemented as needed.
4
4
  class IBaseInfo
5
- def initialize ptr, lib=Lib
5
+ def initialize ptr, lib = Lib
6
6
  raise ArgumentError, "ptr must not be null" if ptr.null?
7
7
 
8
8
  unless defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
@@ -94,7 +94,7 @@ module GObjectIntrospection
94
94
  end
95
95
 
96
96
  def safe_namespace
97
- namespace.gsub(/^(.)/) { $1.upcase }
97
+ namespace.gsub(/^./, &:upcase)
98
98
  end
99
99
 
100
100
  def container
@@ -112,7 +112,7 @@ module GObjectIntrospection
112
112
  end
113
113
 
114
114
  def == other
115
- Lib.g_base_info_equal @gobj, other.to_ptr
115
+ other.is_a?(IBaseInfo) && Lib.g_base_info_equal(@gobj, other)
116
116
  end
117
117
  end
118
118
  end
@@ -23,6 +23,7 @@ module GObjectIntrospection
23
23
 
24
24
  ##
25
25
  build_array_method :properties, :property
26
+ build_finder_method :find_property, :n_properties
26
27
 
27
28
  def get_n_methods
28
29
  Lib.g_interface_info_get_n_methods @gobj
@@ -80,6 +81,5 @@ module GObjectIntrospection
80
81
  def iface_struct
81
82
  IStructInfo.wrap(Lib.g_interface_info_get_iface_struct @gobj)
82
83
  end
83
-
84
84
  end
85
85
  end
@@ -72,7 +72,7 @@ module GObjectIntrospection
72
72
  Lib.g_type_tag_to_string type
73
73
  end
74
74
 
75
- def require namespace, version=nil, flags=0
75
+ def require namespace, version = nil, flags = 0
76
76
  errpp = FFI::MemoryPointer.new(:pointer).write_pointer nil
77
77
 
78
78
  Lib.g_irepository_require @gobj, namespace, version, flags, errpp
@@ -7,7 +7,7 @@ module GObjectIntrospection
7
7
  ffi_lib "girepository-1.0"
8
8
 
9
9
  # IRepository
10
- enum :IRepositoryLoadFlags, [:LAZY, (1<<0)]
10
+ enum :IRepositoryLoadFlags, [:LAZY, (1 << 0)]
11
11
 
12
12
  attach_function :g_irepository_get_default, [], :pointer
13
13
  attach_function :g_irepository_prepend_search_path, [:string], :void
@@ -20,7 +20,7 @@ module GirFFI
20
20
  def fetch ptr
21
21
  return if ptr.null?
22
22
  key = ptr.address
23
- if @store.has_key? key
23
+ if @store.key? key
24
24
  @store[key]
25
25
  else
26
26
  ptr
@@ -74,7 +74,7 @@ module GirFFI
74
74
 
75
75
  def self.cast_uint32_to_int32 val
76
76
  if val >= 0x80000000
77
- -(0x100000000-val)
77
+ -(0x100000000 - val)
78
78
  else
79
79
  val
80
80
  end
@@ -21,7 +21,7 @@ module GirFFI
21
21
  build_class info
22
22
  end
23
23
 
24
- def self.build_module namespace, version=nil
24
+ def self.build_module namespace, version = nil
25
25
  Builders::ModuleBuilder.new(namespace, version).generate
26
26
  end
27
27