gir_ffi 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +8 -0
  3. data/Gemfile +2 -0
  4. data/README.md +2 -2
  5. data/Rakefile +3 -1
  6. data/TODO.md +7 -19
  7. data/lib/ffi-glib/byte_array.rb +1 -1
  8. data/lib/ffi-glib/list.rb +1 -1
  9. data/lib/ffi-glib/main_loop.rb +8 -8
  10. data/lib/ffi-glib/s_list.rb +1 -1
  11. data/lib/ffi-gobject/object.rb +8 -6
  12. data/lib/ffi-gobject/value.rb +2 -2
  13. data/lib/ffi-gobject.rb +5 -1
  14. data/lib/ffi-gobject_introspection/i_arg_info.rb +1 -1
  15. data/lib/ffi-gobject_introspection/i_base_info.rb +1 -1
  16. data/lib/ffi-gobject_introspection/i_callable_info.rb +2 -2
  17. data/lib/ffi-gobject_introspection/i_constant_info.rb +2 -2
  18. data/lib/ffi-gobject_introspection/i_enum_info.rb +2 -2
  19. data/lib/ffi-gobject_introspection/i_field_info.rb +1 -1
  20. data/lib/ffi-gobject_introspection/i_interface_info.rb +9 -9
  21. data/lib/ffi-gobject_introspection/i_object_info.rb +19 -14
  22. data/lib/ffi-gobject_introspection/i_property_info.rb +1 -1
  23. data/lib/ffi-gobject_introspection/i_repository.rb +1 -1
  24. data/lib/ffi-gobject_introspection/i_struct_info.rb +2 -2
  25. data/lib/ffi-gobject_introspection/i_type_info.rb +1 -1
  26. data/lib/ffi-gobject_introspection/i_union_info.rb +3 -3
  27. data/lib/ffi-gobject_introspection/i_vfunc_info.rb +2 -2
  28. data/lib/gir_ffi/builders/argument_builder.rb +2 -1
  29. data/lib/gir_ffi/builders/base_argument_builder.rb +1 -1
  30. data/lib/gir_ffi/builders/boxed_builder.rb +6 -0
  31. data/lib/gir_ffi/builders/closure_to_pointer_convertor.rb +7 -1
  32. data/lib/gir_ffi/builders/field_builder.rb +2 -4
  33. data/lib/gir_ffi/builders/object_builder.rb +20 -9
  34. data/lib/gir_ffi/builders/type_builder.rb +1 -1
  35. data/lib/gir_ffi/builders/unintrospectable_builder.rb +8 -0
  36. data/lib/gir_ffi/builders/with_layout.rb +0 -6
  37. data/lib/gir_ffi/core.rb +2 -1
  38. data/lib/gir_ffi/ffi_ext/pointer.rb +1 -1
  39. data/lib/gir_ffi/info_ext/i_type_info.rb +10 -12
  40. data/lib/gir_ffi/object_base.rb +4 -2
  41. data/lib/gir_ffi/property_not_found_error.rb +12 -0
  42. data/lib/gir_ffi/signal_not_found_error.rb +12 -0
  43. data/lib/gir_ffi/sized_array.rb +4 -4
  44. data/lib/gir_ffi/type_map.rb +1 -1
  45. data/lib/gir_ffi/unintrospectable_boxed_info.rb +2 -1
  46. data/lib/gir_ffi/unintrospectable_signal_info.rb +39 -0
  47. data/lib/gir_ffi/version.rb +2 -1
  48. data/lib/gir_ffi-base/gobject/lib.rb +1 -1
  49. data/tasks/rubocop.rake +5 -0
  50. data/tasks/test.rake +7 -0
  51. data/test/ffi-gobject/object_test.rb +29 -1
  52. data/test/ffi-gobject_introspection/i_object_info_test.rb +16 -0
  53. data/test/ffi-gobject_test.rb +3 -6
  54. data/test/gir_ffi/builders/argument_builder_test.rb +2 -2
  55. data/test/gir_ffi/builders/object_builder_test.rb +25 -12
  56. data/test/gir_ffi/builders/unintrospectable_builder_test.rb +21 -15
  57. data/test/integration/generated_gimarshallingtests_test.rb +16 -13
  58. data/test/integration/generated_gio_test.rb +2 -1
  59. data/test/integration/generated_gobject_test.rb +11 -1
  60. data/test/integration/generated_gst_test.rb +18 -0
  61. data/test/integration/generated_regress_test.rb +6 -8
  62. metadata +21 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 107172036ec9fdf82546c5500d102f21b5776298
4
- data.tar.gz: 21833bf950d07a14f07b7f95d6a59ec12661ea15
3
+ metadata.gz: a091e4dbd8360e158b2fb09d53f34fa6913dda07
4
+ data.tar.gz: 98c7a541d76f2e6217dca26d8cfd2ed5d7b32c71
5
5
  SHA512:
6
- metadata.gz: 7ce027fd3bd08475eb90d7387cef5f48676db5eef27eba9fcfb86d06e6e3cea50a508f76af91f86418d99803f92e6ebe096986451373582780ab299ec506e5cd
7
- data.tar.gz: 7b83c445f3ced66bb2ec47fe026e4fb12f54e76b5896bdc0b7703953e4fc3003ce0ca5986cdb225e9e52992cd6e5bf21b1df89a894fe6f334b23b0ec95708b31
6
+ metadata.gz: 1aaf7d901357faa26299c194deedb7a6cd42dafd62bb50e5f30c0c364ce4ef25349381deac8a4da8e42aa0d26d6d6bb2f0d1019884bf9c92a55fa03770df6485
7
+ data.tar.gz: cfd6c0d21b4f674c1fd637f4d8d963158f29264e046204021fb539594a1015f0807c279047c998b71fca4bc8f53ca2d750edd433af3800fab01e6727ec548ccd
data/Changelog.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.1 / 2016-02-04
4
+
5
+ * Add field accessors for Object types for fields that don't have corresponding
6
+ properties or getter methods
7
+ * Improve error handling for signals and properties that are not found
8
+ * Handle signals without GIR data
9
+ * Add interrupt handler to break out of main loops
10
+
3
11
  ## 0.9.0 / 2016-01-21
4
12
 
5
13
  * Propagate exceptions from callbacks during event loops
data/Gemfile CHANGED
@@ -3,6 +3,8 @@ source 'https://rubygems.org'
3
3
  # The gem's dependencies are specified in gir_ffi.gemspec
4
4
  gemspec
5
5
 
6
+ gem 'rubocop', '~> 0.36.0', type: :development
7
+
6
8
  if ENV['CI']
7
9
  if ENV['TRAVIS_RUBY_VERSION'] == '2.2'
8
10
  gem 'coveralls', type: :development
data/README.md CHANGED
@@ -64,8 +64,8 @@ GirFFI is developed on Debian sid, and tested through Travis CI on Ubuntu
64
64
  are therefore not officially supported (although they may work).
65
65
 
66
66
  On Debian and Ubuntu, installing `libgirepository1.0-dev`,
67
- `gobject-introspection` and `gir1.2-gtop-2.0` should be enough to get
68
- `rake test` working.
67
+ `gobject-introspection`, `gir1.2-gtop-2.0` and `gir1.2-gstreamer-1.0` should be
68
+ enough to get `rake test` working.
69
69
 
70
70
  GirFFI has not been tested on Mac OS X or Microsoft Windows. YMMV.
71
71
 
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'rake/clean'
2
2
  require 'bundler/gem_tasks'
3
3
 
4
+ load 'tasks/rubocop.rake'
4
5
  load 'tasks/test.rake'
5
6
 
6
- task :default => 'test:all'
7
+ task default: :test
8
+ task default: :rubocop unless RUBY_ENGINE == 'rbx'
data/TODO.md CHANGED
@@ -1,25 +1,12 @@
1
1
  # TODO
2
2
 
3
- ## Miscellaneous
4
-
5
- * MAKE CONSTRUCTOR_WRAP CHECK TYPES? This would allow GObject::Object.new to
6
- work and create the correct subtype for classes that don't define their own
7
- default constructor.
8
- * Add tests for the other test files in gobject-introspection. Currently, only
9
- regress.c and gimarshallingtests.c are used, but there are 6 other files
10
- available.
11
- * Move GObjectIntrospection to GIRepository, and allow generating its own
12
- members.
13
- * Do not remove ClassBase.new. We now remove it and then add it back for the
14
- default constructor, which is kind of silly.
15
-
16
3
  ## Memory managment
17
4
 
18
- GirFFI does not attempt to free any memory at the moment, or lower the
5
+ GirFFI does not ~~attempt to free any memory at the moment, or~~ lower the
19
6
  reference count of any objects it gets from GObject. This task therefore involves two parts:
20
7
 
21
8
  - Free non-GObject pointers as needed (at garbage-collection time)
22
- - Lower reference count of GObjects (at garbage-collection time) (done!)
9
+ - [Done!] Lower reference count of GObjects (at garbage-collection time)
23
10
 
24
11
  **Use memory_profiler to check memory use (https://github.com/SamSaffron/memory_profiler)**
25
12
 
@@ -37,10 +24,6 @@ These in the order they occured to me, and may therefore be fixed in any order.
37
24
  - Move to a single Pointer class, rather than InPointer, InOutPointer and
38
25
  Pointer monkeypatching.
39
26
 
40
- - Move special types like SizedArray to sane namespaces. Types (like
41
- GLib::List) that have actual GLib implementations go to the GLib namespace.
42
- Other types go to the GirFFI namespace.
43
-
44
27
  ## Derived types
45
28
 
46
29
  Derived classes can now be registered with GObject, but the way to do this is
@@ -117,6 +100,11 @@ to be put in place for that.
117
100
 
118
101
  For how to handle objects, see https://bugzilla.gnome.org/show_bug.cgi?id=657202#c1
119
102
 
103
+ ## Miscellaneous
104
+
105
+ * Move GObjectIntrospection to GIRepository, and allow generating its own
106
+ members.
107
+
120
108
  ## External dependencies
121
109
 
122
110
  Things that I think GirFFI cannot fix:
@@ -10,7 +10,7 @@ module GLib
10
10
  def append(data)
11
11
  bytes = GirFFI::InPointer.from :utf8, data
12
12
  len = data.bytesize
13
- self.class.wrap(Lib.g_byte_array_append to_ptr, bytes, len)
13
+ self.class.wrap Lib.g_byte_array_append(to_ptr, bytes, len)
14
14
  end
15
15
 
16
16
  def initialize
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.reduce(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)
@@ -26,7 +26,7 @@ module GLib
26
26
 
27
27
  def handler_proc
28
28
  proc do
29
- Thread.pass
29
+ ::Thread.pass
30
30
  true
31
31
  end
32
32
  end
@@ -53,16 +53,16 @@ module GLib
53
53
  end
54
54
 
55
55
  def self.handle_exception(ex)
56
- current_loop = RUNNING_LOOPS.last
57
- if current_loop
58
- EXCEPTIONS << ex
59
- current_loop.quit
60
- else
61
- raise ex
62
- end
56
+ raise ex unless (current_loop = RUNNING_LOOPS.last)
57
+ EXCEPTIONS << ex
58
+ current_loop.quit
63
59
  end
64
60
 
65
61
  alias_method :run_without_thread_enabler, :run
66
62
  alias_method :run, :run_with_thread_enabler
67
63
  end
68
64
  end
65
+
66
+ Signal.trap 'INT' do
67
+ GLib::MainLoop.handle_exception(Interrupt.new)
68
+ end
@@ -8,7 +8,7 @@ module GLib
8
8
  include ListMethods
9
9
 
10
10
  def self.from_enumerable(type, arr)
11
- arr.reverse.reduce(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)
@@ -1,3 +1,5 @@
1
+ require 'gir_ffi/property_not_found_error'
2
+
1
3
  GObject.load_class :Object
2
4
 
3
5
  module GObject
@@ -8,9 +10,7 @@ module GObject
8
10
  def initialize_with_automatic_gtype(properties = {})
9
11
  gparameters = properties.map do |name, value|
10
12
  name = name.to_s
11
- unless property_param_spec(name)
12
- raise ArgumentError, "Property '#{name}' not found in class #{self.class}"
13
- end
13
+ property_param_spec(name)
14
14
  GObject::Parameter.new.tap do |gparam|
15
15
  gparam.name = name
16
16
  gparam.value = value
@@ -106,7 +106,7 @@ module GObject
106
106
  private
107
107
 
108
108
  def get_property_type(property_name)
109
- prop = self.class.find_property property_name
109
+ prop = self.class.find_property(property_name)
110
110
  prop.property_type
111
111
  end
112
112
 
@@ -116,11 +116,13 @@ module GObject
116
116
  end
117
117
 
118
118
  def property_gtype(property_name)
119
- property_param_spec(property_name).value_type
119
+ pspec = property_param_spec(property_name)
120
+ pspec.value_type
120
121
  end
121
122
 
122
123
  def property_param_spec(property_name)
123
- object_class.find_property property_name
124
+ object_class.find_property property_name or
125
+ raise GirFFI::PropertyNotFoundError.new(property_name, self.class)
124
126
  end
125
127
 
126
128
  # TODO: Move to ITypeInfo
@@ -45,7 +45,7 @@ module GObject
45
45
  TYPE_OBJECT => [:get_object, :set_instance_enhanced],
46
46
  TYPE_GTYPE => [:get_gtype, :set_gtype],
47
47
  TYPE_VARIANT => [:get_variant, :set_variant]
48
- }
48
+ }.freeze
49
49
 
50
50
  def set_value(val)
51
51
  send set_method, val
@@ -119,7 +119,7 @@ module GObject
119
119
  FalseClass => TYPE_BOOLEAN,
120
120
  Integer => TYPE_INT,
121
121
  String => TYPE_STRING
122
- }
122
+ }.freeze
123
123
 
124
124
  def init_for_ruby_value(val)
125
125
  if val.class.respond_to? :gtype
data/lib/ffi-gobject.rb CHANGED
@@ -10,7 +10,7 @@ require 'ffi-gobject/closure'
10
10
  require 'ffi-gobject/object'
11
11
  require 'ffi-gobject/object_class'
12
12
  require 'ffi-gobject/ruby_closure'
13
- require 'gir_ffi/builders/user_defined_builder'
13
+ require 'gir_ffi/signal_not_found_error'
14
14
 
15
15
  # Module representing GLib's GObject namespace.
16
16
  module GObject
@@ -24,6 +24,10 @@ module GObject
24
24
  type_from_instance_pointer instance.to_ptr
25
25
  end
26
26
 
27
+ def self.type_name_from_instance(instance)
28
+ type_name type_from_instance instance
29
+ end
30
+
27
31
  def self.object_class_from_instance(instance)
28
32
  object_class_from_instance_pointer instance.to_ptr
29
33
  end
@@ -44,7 +44,7 @@ module GObjectIntrospection
44
44
  end
45
45
 
46
46
  def argument_type
47
- ITypeInfo.wrap(Lib.g_arg_info_get_type @gobj)
47
+ ITypeInfo.wrap Lib.g_arg_info_get_type(@gobj)
48
48
  end
49
49
  end
50
50
  end
@@ -67,7 +67,7 @@ module GObjectIntrospection
67
67
  method = method.to_s
68
68
  single = method.sub(/^find_/, '')
69
69
  counter ||= "n_#{single}s"
70
- fetcher ||= "#{single}"
70
+ fetcher ||= single
71
71
  class_eval <<-CODE
72
72
  def #{method}(name)
73
73
  name = name.to_s
@@ -7,7 +7,7 @@ module GObjectIntrospection
7
7
  # IFunctionInfo, ICallbackInfo or IVFuncInfo.
8
8
  class ICallableInfo < IBaseInfo
9
9
  def return_type
10
- ITypeInfo.wrap(Lib.g_callable_info_get_return_type @gobj)
10
+ ITypeInfo.wrap Lib.g_callable_info_get_return_type(@gobj)
11
11
  end
12
12
 
13
13
  def caller_owns
@@ -23,7 +23,7 @@ module GObjectIntrospection
23
23
  end
24
24
 
25
25
  def arg(index)
26
- IArgInfo.wrap(Lib.g_callable_info_get_arg @gobj, index)
26
+ IArgInfo.wrap Lib.g_callable_info_get_arg(@gobj, index)
27
27
  end
28
28
  ##
29
29
  build_array_method :args
@@ -13,7 +13,7 @@ module GObjectIntrospection
13
13
  guint64: :v_uint64,
14
14
  gdouble: :v_double,
15
15
  utf8: :v_string
16
- }
16
+ }.freeze
17
17
 
18
18
  def value
19
19
  case type_tag
@@ -27,7 +27,7 @@ module GObjectIntrospection
27
27
  end
28
28
 
29
29
  def constant_type
30
- ITypeInfo.wrap(Lib.g_constant_info_get_type @gobj)
30
+ ITypeInfo.wrap Lib.g_constant_info_get_type(@gobj)
31
31
  end
32
32
 
33
33
  private
@@ -7,7 +7,7 @@ module GObjectIntrospection
7
7
  end
8
8
 
9
9
  def value(index)
10
- IValueInfo.wrap(Lib.g_enum_info_get_value @gobj, index)
10
+ IValueInfo.wrap Lib.g_enum_info_get_value(@gobj, index)
11
11
  end
12
12
  ##
13
13
  build_array_method :values
@@ -17,7 +17,7 @@ module GObjectIntrospection
17
17
  end
18
18
 
19
19
  def get_method(index)
20
- IFunctionInfo.wrap(Lib.g_enum_info_get_method @gobj, index)
20
+ IFunctionInfo.wrap Lib.g_enum_info_get_method(@gobj, index)
21
21
  end
22
22
 
23
23
  ##
@@ -15,7 +15,7 @@ module GObjectIntrospection
15
15
  end
16
16
 
17
17
  def field_type
18
- ITypeInfo.wrap(Lib.g_field_info_get_type @gobj)
18
+ ITypeInfo.wrap Lib.g_field_info_get_type(@gobj)
19
19
  end
20
20
 
21
21
  def readable?
@@ -7,7 +7,7 @@ module GObjectIntrospection
7
7
  end
8
8
 
9
9
  def prerequisite(index)
10
- IBaseInfo.wrap(Lib.g_interface_info_get_prerequisite @gobj, index)
10
+ IBaseInfo.wrap Lib.g_interface_info_get_prerequisite(@gobj, index)
11
11
  end
12
12
 
13
13
  ##
@@ -18,7 +18,7 @@ module GObjectIntrospection
18
18
  end
19
19
 
20
20
  def property(index)
21
- IPropertyInfo.wrap(Lib.g_interface_info_get_property @gobj, index)
21
+ IPropertyInfo.wrap Lib.g_interface_info_get_property(@gobj, index)
22
22
  end
23
23
 
24
24
  ##
@@ -30,14 +30,14 @@ module GObjectIntrospection
30
30
  end
31
31
 
32
32
  def get_method(index)
33
- IFunctionInfo.wrap(Lib.g_interface_info_get_method @gobj, index)
33
+ IFunctionInfo.wrap Lib.g_interface_info_get_method(@gobj, index)
34
34
  end
35
35
 
36
36
  ##
37
37
  build_array_method :get_methods
38
38
 
39
39
  def find_method(name)
40
- IFunctionInfo.wrap(Lib.g_interface_info_find_method @gobj, name.to_s)
40
+ IFunctionInfo.wrap Lib.g_interface_info_find_method(@gobj, name.to_s)
41
41
  end
42
42
 
43
43
  def n_signals
@@ -45,7 +45,7 @@ module GObjectIntrospection
45
45
  end
46
46
 
47
47
  def signal(index)
48
- ISignalInfo.wrap(Lib.g_interface_info_get_signal @gobj, index)
48
+ ISignalInfo.wrap Lib.g_interface_info_get_signal(@gobj, index)
49
49
  end
50
50
 
51
51
  ##
@@ -57,14 +57,14 @@ module GObjectIntrospection
57
57
  end
58
58
 
59
59
  def vfunc(index)
60
- IVFuncInfo.wrap(Lib.g_interface_info_get_vfunc @gobj, index)
60
+ IVFuncInfo.wrap Lib.g_interface_info_get_vfunc(@gobj, index)
61
61
  end
62
62
 
63
63
  ##
64
64
  build_array_method :vfuncs
65
65
 
66
66
  def find_vfunc(name)
67
- IVFuncInfo.wrap(Lib.g_interface_info_find_vfunc @gobj, name)
67
+ IVFuncInfo.wrap Lib.g_interface_info_find_vfunc(@gobj, name)
68
68
  end
69
69
 
70
70
  def n_constants
@@ -72,14 +72,14 @@ module GObjectIntrospection
72
72
  end
73
73
 
74
74
  def constant(index)
75
- IConstantInfo.wrap(Lib.g_interface_info_get_constant @gobj, index)
75
+ IConstantInfo.wrap Lib.g_interface_info_get_constant(@gobj, index)
76
76
  end
77
77
 
78
78
  ##
79
79
  build_array_method :constants
80
80
 
81
81
  def iface_struct
82
- IStructInfo.wrap(Lib.g_interface_info_get_iface_struct @gobj)
82
+ IStructInfo.wrap Lib.g_interface_info_get_iface_struct(@gobj)
83
83
  end
84
84
  end
85
85
  end
@@ -19,7 +19,7 @@ module GObjectIntrospection
19
19
  end
20
20
 
21
21
  def parent
22
- IObjectInfo.wrap(Lib.g_object_info_get_parent @gobj)
22
+ IObjectInfo.wrap Lib.g_object_info_get_parent(@gobj)
23
23
  end
24
24
 
25
25
  def n_interfaces
@@ -27,7 +27,7 @@ module GObjectIntrospection
27
27
  end
28
28
 
29
29
  def interface(index)
30
- IInterfaceInfo.wrap(Lib.g_object_info_get_interface @gobj, index)
30
+ IInterfaceInfo.wrap Lib.g_object_info_get_interface(@gobj, index)
31
31
  end
32
32
 
33
33
  ##
@@ -38,7 +38,7 @@ module GObjectIntrospection
38
38
  end
39
39
 
40
40
  def field(index)
41
- IFieldInfo.wrap(Lib.g_object_info_get_field @gobj, index)
41
+ IFieldInfo.wrap Lib.g_object_info_get_field(@gobj, index)
42
42
  end
43
43
 
44
44
  ##
@@ -49,26 +49,31 @@ module GObjectIntrospection
49
49
  end
50
50
 
51
51
  def property(index)
52
- IPropertyInfo.wrap(Lib.g_object_info_get_property @gobj, index)
52
+ IPropertyInfo.wrap Lib.g_object_info_get_property(@gobj, index)
53
53
  end
54
54
 
55
- ##
56
- build_array_method :properties, :property
57
- build_finder_method :find_property, :n_properties
55
+ def properties
56
+ @properties ||= Array.new(n_properties) { |idx| property(idx) }
57
+ end
58
+
59
+ def find_property(name)
60
+ name = name.to_s.tr('_', '-')
61
+ properties.find { |prop| prop.name == name }
62
+ end
58
63
 
59
64
  def get_n_methods
60
65
  Lib.g_object_info_get_n_methods @gobj
61
66
  end
62
67
 
63
68
  def get_method(index)
64
- IFunctionInfo.wrap(Lib.g_object_info_get_method @gobj, index)
69
+ IFunctionInfo.wrap Lib.g_object_info_get_method(@gobj, index)
65
70
  end
66
71
 
67
72
  ##
68
73
  build_array_method :get_methods
69
74
 
70
75
  def find_method(name)
71
- IFunctionInfo.wrap(Lib.g_object_info_find_method @gobj, name.to_s)
76
+ IFunctionInfo.wrap Lib.g_object_info_find_method(@gobj, name.to_s)
72
77
  end
73
78
 
74
79
  def n_signals
@@ -76,7 +81,7 @@ module GObjectIntrospection
76
81
  end
77
82
 
78
83
  def signal(index)
79
- ISignalInfo.wrap(Lib.g_object_info_get_signal @gobj, index)
84
+ ISignalInfo.wrap Lib.g_object_info_get_signal(@gobj, index)
80
85
  end
81
86
 
82
87
  ##
@@ -88,11 +93,11 @@ module GObjectIntrospection
88
93
  end
89
94
 
90
95
  def vfunc(index)
91
- IVFuncInfo.wrap(Lib.g_object_info_get_vfunc @gobj, index)
96
+ IVFuncInfo.wrap Lib.g_object_info_get_vfunc(@gobj, index)
92
97
  end
93
98
 
94
99
  def find_vfunc(name)
95
- IVFuncInfo.wrap(Lib.g_object_info_find_vfunc @gobj, name.to_s)
100
+ IVFuncInfo.wrap Lib.g_object_info_find_vfunc(@gobj, name.to_s)
96
101
  end
97
102
  ##
98
103
  build_array_method :vfuncs
@@ -102,13 +107,13 @@ module GObjectIntrospection
102
107
  end
103
108
 
104
109
  def constant(index)
105
- IConstantInfo.wrap(Lib.g_object_info_get_constant @gobj, index)
110
+ IConstantInfo.wrap Lib.g_object_info_get_constant(@gobj, index)
106
111
  end
107
112
  ##
108
113
  build_array_method :constants
109
114
 
110
115
  def class_struct
111
- IStructInfo.wrap(Lib.g_object_info_get_class_struct @gobj)
116
+ IStructInfo.wrap Lib.g_object_info_get_class_struct(@gobj)
112
117
  end
113
118
  end
114
119
  end
@@ -3,7 +3,7 @@ module GObjectIntrospection
3
3
  # Represents a property of an IObjectInfo or an IInterfaceInfo.
4
4
  class IPropertyInfo < IBaseInfo
5
5
  def property_type
6
- ITypeInfo.wrap(Lib.g_property_info_get_type @gobj)
6
+ ITypeInfo.wrap Lib.g_property_info_get_type(@gobj)
7
7
  end
8
8
 
9
9
  def flags
@@ -51,7 +51,7 @@ module GObjectIntrospection
51
51
  arg: IArgInfo,
52
52
  type: ITypeInfo,
53
53
  unresolved: IUnresolvedInfo
54
- }
54
+ }.freeze
55
55
 
56
56
  def initialize
57
57
  @gobj = Lib.g_irepository_get_default
@@ -7,7 +7,7 @@ module GObjectIntrospection
7
7
  end
8
8
 
9
9
  def field(index)
10
- IFieldInfo.wrap(Lib.g_struct_info_get_field @gobj, index)
10
+ IFieldInfo.wrap Lib.g_struct_info_get_field(@gobj, index)
11
11
  end
12
12
 
13
13
  ##
@@ -19,7 +19,7 @@ module GObjectIntrospection
19
19
  end
20
20
 
21
21
  def get_method(index)
22
- IFunctionInfo.wrap(Lib.g_struct_info_get_method @gobj, index)
22
+ IFunctionInfo.wrap Lib.g_struct_info_get_method(@gobj, index)
23
23
  end
24
24
 
25
25
  ##
@@ -11,7 +11,7 @@ module GObjectIntrospection
11
11
  end
12
12
 
13
13
  def param_type(index)
14
- ITypeInfo.wrap(Lib.g_type_info_get_param_type @gobj, index)
14
+ ITypeInfo.wrap Lib.g_type_info_get_param_type(@gobj, index)
15
15
  end
16
16
 
17
17
  def interface
@@ -7,7 +7,7 @@ module GObjectIntrospection
7
7
  end
8
8
 
9
9
  def field(index)
10
- IFieldInfo.wrap(Lib.g_union_info_get_field @gobj, index)
10
+ IFieldInfo.wrap Lib.g_union_info_get_field(@gobj, index)
11
11
  end
12
12
 
13
13
  ##
@@ -18,14 +18,14 @@ module GObjectIntrospection
18
18
  end
19
19
 
20
20
  def get_method(index)
21
- IFunctionInfo.wrap(Lib.g_union_info_get_method @gobj, index)
21
+ IFunctionInfo.wrap Lib.g_union_info_get_method(@gobj, index)
22
22
  end
23
23
 
24
24
  ##
25
25
  build_array_method :get_methods
26
26
 
27
27
  def find_method(name)
28
- IFunctionInfo.wrap(Lib.g_union_info_find_method @gobj, name.to_s)
28
+ IFunctionInfo.wrap Lib.g_union_info_find_method(@gobj, name.to_s)
29
29
  end
30
30
 
31
31
  def size
@@ -15,11 +15,11 @@ module GObjectIntrospection
15
15
  end
16
16
 
17
17
  def signal
18
- ISignalInfo.wrap(Lib.g_vfunc_info_get_signal @gobj)
18
+ ISignalInfo.wrap Lib.g_vfunc_info_get_signal(@gobj)
19
19
  end
20
20
 
21
21
  def invoker
22
- IFunctionInfo.wrap(Lib.g_vfunc_info_get_invoker @gobj)
22
+ IFunctionInfo.wrap Lib.g_vfunc_info_get_invoker(@gobj)
23
23
  end
24
24
  end
25
25
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'gir_ffi/builders/base_argument_builder'
2
3
  require 'gir_ffi/builders/closure_to_pointer_convertor'
3
4
  require 'gir_ffi/builders/full_c_to_ruby_convertor'
@@ -147,7 +148,7 @@ module GirFFI
147
148
  @arginfo.caller_allocates?
148
149
  end
149
150
 
150
- DESTROY_NOTIFIER = 'GLib::DestroyNotify.default'
151
+ DESTROY_NOTIFIER = 'GLib::DestroyNotify.default'.freeze
151
152
 
152
153
  def ingoing_convertor
153
154
  if skipped?
@@ -10,7 +10,7 @@ module GirFFI
10
10
  module next nil not or redo rescue retry
11
11
  return self super then true undef unless
12
12
  until when while yield
13
- )
13
+ ).freeze
14
14
 
15
15
  attr_reader :arginfo
16
16
  attr_accessor :length_arg, :array_arg
@@ -15,6 +15,12 @@ module GirFFI
15
15
  stub_methods
16
16
  setup_field_accessors
17
17
  end
18
+
19
+ def setup_field_accessors
20
+ fields.each do |finfo|
21
+ FieldBuilder.new(finfo).build
22
+ end
23
+ end
18
24
  end
19
25
  end
20
26
  end
@@ -9,7 +9,13 @@ module GirFFI
9
9
  end
10
10
 
11
11
  def conversion
12
- "GirFFI::InPointer.from_closure_data(#{@callback_argument.call_argument_name}.object_id)"
12
+ "GirFFI::InPointer.from_closure_data(#{callback_argument_name}.object_id)"
13
+ end
14
+
15
+ private
16
+
17
+ def callback_argument_name
18
+ @callback_argument.call_argument_name
13
19
  end
14
20
  end
15
21
  end