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
@@ -9,37 +9,39 @@ module GirFFI
9
9
  # Implements building pre- and post-processing statements for arguments.
10
10
  class ArgumentBuilder < BaseArgumentBuilder
11
11
  def method_argument_name
12
- if has_input_value? && !is_array_length_parameter?
13
- name
14
- end
12
+ name if has_input_value? && !array_length_parameter?
15
13
  end
16
14
 
17
15
  def post_converted_name
18
16
  @post_converted_name ||= if has_post_conversion?
19
17
  new_variable
20
18
  else
21
- callarg
19
+ call_argument_name
22
20
  end
23
21
  end
24
22
 
25
23
  def return_value_name
26
24
  if has_output_value?
27
- post_converted_name unless is_array_length_parameter?
25
+ post_converted_name unless array_length_parameter?
28
26
  end
29
27
  end
30
28
 
29
+ def capture_variable_name
30
+ nil
31
+ end
32
+
31
33
  def pre_conversion
32
34
  pr = []
33
35
  case direction
34
36
  when :in
35
37
  pr << fixed_array_size_check if needs_size_check?
36
- pr << array_length_assignment if is_array_length_parameter?
37
- pr << "#{callarg} = #{ingoing_convertor.conversion}"
38
+ pr << array_length_assignment if array_length_parameter?
39
+ pr << "#{call_argument_name} = #{ingoing_convertor.conversion}"
38
40
  when :inout
39
41
  pr << fixed_array_size_check if needs_size_check?
40
- pr << array_length_assignment if is_array_length_parameter?
42
+ pr << array_length_assignment if array_length_parameter?
41
43
  pr << out_parameter_preparation
42
- pr << "#{callarg}.set_value #{ingoing_convertor.conversion}"
44
+ pr << "#{call_argument_name}.set_value #{ingoing_convertor.conversion}"
43
45
  when :out
44
46
  pr << out_parameter_preparation
45
47
  end
@@ -58,11 +60,11 @@ module GirFFI
58
60
  private
59
61
 
60
62
  def has_post_conversion?
61
- has_output_value? && !is_caller_allocated_object?
63
+ has_output_value? && !caller_allocated_object?
62
64
  end
63
65
 
64
66
  def output_value
65
- base = "#{callarg}.to_value"
67
+ base = "#{call_argument_name}.to_value"
66
68
  if needs_out_conversion?
67
69
  CToRubyConvertor.new(@type_info, base, length_argument_name).conversion
68
70
  elsif allocated_by_them?
@@ -88,7 +90,7 @@ module GirFFI
88
90
  length_arg && length_arg.post_converted_name
89
91
  end
90
92
 
91
- def is_array_length_parameter?
93
+ def array_length_parameter?
92
94
  @array_arg
93
95
  end
94
96
 
@@ -120,7 +122,7 @@ module GirFFI
120
122
  end
121
123
 
122
124
  def out_parameter_preparation
123
- value = if is_caller_allocated_object?
125
+ value = if caller_allocated_object?
124
126
  if specialized_type_tag == :array
125
127
  "#{argument_class_name}.new #{type_info.element_type.inspect}"
126
128
  else
@@ -129,18 +131,18 @@ module GirFFI
129
131
  else
130
132
  "GirFFI::InOutPointer.for #{type_info.tag_or_class.inspect}"
131
133
  end
132
- "#{callarg} = #{value}"
134
+ "#{call_argument_name} = #{value}"
133
135
  end
134
136
 
135
- def is_caller_allocated_object?
136
- [ :struct, :array ].include?(specialized_type_tag) &&
137
+ def caller_allocated_object?
138
+ [:struct, :array].include?(specialized_type_tag) &&
137
139
  @arginfo.caller_allocates?
138
140
  end
139
141
 
140
142
  def ingoing_convertor
141
143
  if skipped?
142
144
  NullConvertor.new("0")
143
- elsif is_closure
145
+ elsif closure?
144
146
  ClosureToPointerConvertor.new(name)
145
147
  elsif @type_info.needs_ruby_to_c_conversion_for_functions?
146
148
  RubyToCConvertor.new(@type_info, name)
@@ -5,23 +5,21 @@ module GirFFI
5
5
  # and parameter and variable names for use by function builders.
6
6
  class ArgumentBuilderCollection
7
7
  attr_reader :return_value_builder
8
- attr_reader :argument_builders
9
8
 
10
9
  def initialize return_value_builder, argument_builders, options = {}
11
10
  @receiver_builder = options[:receiver_builder]
12
- @argument_builders = argument_builders
11
+ @error_argument_builder = options[:error_argument_builder]
12
+ @base_argument_builders = argument_builders
13
13
  @return_value_builder = return_value_builder
14
- self.class.set_up_argument_relations argument_builders
15
- @argument_builders.unshift @receiver_builder if @receiver_builder
14
+ set_up_argument_relations
16
15
  end
17
16
 
18
17
  def parameter_preparation
19
- argument_builders.sort_by.with_index {|arg, i|
20
- [arg.type_info.array_length, i] }.map(&:pre_conversion).flatten
18
+ builders_for_pre_conversion.map(&:pre_conversion).flatten
21
19
  end
22
20
 
23
21
  def return_value_conversion
24
- all_builders.map(&:post_conversion).flatten
22
+ builders_for_post_conversion.map(&:post_conversion).flatten
25
23
  end
26
24
 
27
25
  def capture_variable_names
@@ -34,22 +32,39 @@ module GirFFI
34
32
  end
35
33
 
36
34
  def method_argument_names
37
- @method_argument_names ||= argument_builders.map(&:method_argument_name)
35
+ @method_argument_names ||= argument_builders.map(&:method_argument_name).compact
38
36
  end
39
37
 
40
38
  def return_value_name
41
- return_value_builder.return_value_name if return_value_builder.is_relevant?
39
+ return_value_builder.return_value_name if return_value_builder.relevant?
42
40
  end
43
41
 
44
- def self.set_up_argument_relations argument_builders
45
- argument_builders.each do |arg|
42
+ def return_value_names
43
+ @return_value_names ||= all_builders.map(&:return_value_name).compact
44
+ end
45
+
46
+ def has_return_values?
47
+ return_value_names.any?
48
+ end
49
+
50
+ private
51
+
52
+ def argument_builders
53
+ @argument_builders ||= @base_argument_builders.dup.tap do |builders|
54
+ builders.unshift @receiver_builder if @receiver_builder
55
+ builders.push @error_argument_builder if @error_argument_builder
56
+ end
57
+ end
58
+
59
+ def set_up_argument_relations
60
+ @base_argument_builders.each do |arg|
46
61
  if (idx = arg.arginfo.closure) >= 0
47
- argument_builders[idx].is_closure = true
62
+ @base_argument_builders[idx].closure = true
48
63
  end
49
64
  end
50
- argument_builders.each do |bldr|
65
+ all_builders.each do |bldr|
51
66
  if (idx = bldr.array_length_idx) >= 0
52
- other = argument_builders[idx]
67
+ other = @base_argument_builders[idx]
53
68
 
54
69
  bldr.length_arg = other
55
70
  other.array_arg = bldr
@@ -57,11 +72,31 @@ module GirFFI
57
72
  end
58
73
  end
59
74
 
60
- private
61
-
62
75
  def all_builders
63
76
  @all_builders ||= [return_value_builder] + argument_builders
64
77
  end
78
+
79
+ def builders_for_pre_conversion
80
+ @builders_for_pre_conversion ||=
81
+ sorted_base_argument_builders.dup.tap do |builders|
82
+ builders.unshift @receiver_builder if @receiver_builder
83
+ builders.push @error_argument_builder if @error_argument_builder
84
+ end
85
+ end
86
+
87
+ def builders_for_post_conversion
88
+ @builders_for_post_conversion ||=
89
+ sorted_base_argument_builders.dup.tap do |builders|
90
+ builders.unshift @receiver_builder if @receiver_builder
91
+ builders.unshift @error_argument_builder if @error_argument_builder
92
+ builders.push return_value_builder
93
+ end
94
+ end
95
+
96
+ def sorted_base_argument_builders
97
+ @sorted_base_argument_builders ||= @base_argument_builders.
98
+ sort_by.with_index { |arg, i| [arg.array_length_idx, i] }
99
+ end
65
100
  end
66
101
  end
67
102
  end
@@ -4,17 +4,27 @@ module GirFFI
4
4
  # classes are used by FunctionBuilder to create the code that
5
5
  # processes each argument before and after the actual function call.
6
6
  class BaseArgumentBuilder
7
- KEYWORDS = [
8
- "alias", "and", "begin", "break", "case", "class", "def", "do",
9
- "else", "elsif", "end", "ensure", "false", "for", "if", "in",
10
- "module", "next", "nil", "not", "or", "redo", "rescue", "retry",
11
- "return", "self", "super", "then", "true", "undef", "unless",
12
- "until", "when", "while", "yield"
13
- ]
7
+ KEYWORDS = %w(
8
+ alias and begin break case class def do
9
+ else elsif end ensure false for if in
10
+ module next nil not or redo rescue retry
11
+ return self super then true undef unless
12
+ until when while yield
13
+ )
14
14
 
15
15
  attr_reader :arginfo
16
16
  attr_accessor :length_arg, :array_arg
17
- attr_accessor :is_closure
17
+
18
+ # TODO: closure unfortunately means two things in GLib: a closure
19
+ # argument (user_data), and the Closure class (a callable object). Make
20
+ # the distinction more explicit in GirFFI.
21
+ def closure?
22
+ @is_closure
23
+ end
24
+
25
+ def closure= arg
26
+ @is_closure = arg
27
+ end
18
28
 
19
29
  def initialize var_gen, arginfo
20
30
  @var_gen = var_gen
@@ -58,8 +68,8 @@ module GirFFI
58
68
  end
59
69
  end
60
70
 
61
- def callarg
62
- @callarg ||= new_variable
71
+ def call_argument_name
72
+ @call_argument_name ||= new_variable
63
73
  end
64
74
 
65
75
  def new_variable
@@ -1,7 +1,6 @@
1
1
  require 'gir_ffi/builder_helper'
2
2
 
3
3
  module GirFFI
4
-
5
4
  # Base class for type builders.
6
5
  class BaseTypeBuilder
7
6
  include BuilderHelper
@@ -13,12 +12,14 @@ module GirFFI
13
12
  end
14
13
 
15
14
  def build_class
16
- unless defined? @klass
17
- instantiate_class
18
- end
15
+ instantiate_class unless defined? @klass
19
16
  @klass
20
17
  end
21
18
 
19
+ def instantiate_class
20
+ setup_class unless already_set_up
21
+ end
22
+
22
23
  attr_reader :info
23
24
 
24
25
  private
@@ -28,7 +29,7 @@ module GirFFI
28
29
  end
29
30
 
30
31
  def lib
31
- @lib ||= namespace_module.const_get :Lib
32
+ @lib ||= namespace_module::Lib
32
33
  end
33
34
 
34
35
  def setup_constants
@@ -29,9 +29,9 @@ module GirFFI
29
29
  def pre_conversion
30
30
  case direction
31
31
  when :in
32
- [ "#{pre_converted_name} = #{pre_convertor.conversion}" ]
32
+ ["#{pre_converted_name} = #{pre_convertor.conversion}"]
33
33
  when :out
34
- [ "#{pre_converted_name} = #{out_parameter_preparation}" ]
34
+ ["#{pre_converted_name} = #{out_parameter_preparation}"]
35
35
  when :error
36
36
  [
37
37
  "#{pre_converted_name} = #{out_parameter_preparation}",
@@ -43,7 +43,7 @@ module GirFFI
43
43
  def post_conversion
44
44
  case direction
45
45
  when :out
46
- [ outgoing_post_conversion ]
46
+ [outgoing_post_conversion]
47
47
  when :error
48
48
  [
49
49
  "rescue => #{result_name}",
@@ -62,7 +62,7 @@ module GirFFI
62
62
  end
63
63
 
64
64
  def pre_convertor
65
- @pre_convertor ||= if is_closure
65
+ @pre_convertor ||= if closure?
66
66
  ClosureConvertor.new(method_argument_name)
67
67
  elsif needs_c_to_ruby_conversion?
68
68
  CToRubyConvertor.new(type_info,
@@ -92,7 +92,7 @@ module GirFFI
92
92
  def out_parameter_preparation
93
93
  type_spec = type_info.tag_or_class
94
94
  if allocated_by_us?
95
- "GirFFI::InOutPointer.new(#{type_spec[1].inspect})" +
95
+ "GirFFI::InOutPointer.new(#{type_spec[1].inspect})" \
96
96
  ".tap { |ptr| #{method_argument_name}.put_pointer 0, ptr }"
97
97
  else
98
98
  "GirFFI::InOutPointer.new(#{type_spec.inspect}, #{method_argument_name})"
@@ -8,10 +8,6 @@ module GirFFI
8
8
  # attached to the appropriate namespace module, and will be defined
9
9
  # as a callback for FFI.
10
10
  class CallbackBuilder < BaseTypeBuilder
11
- def instantiate_class
12
- setup_class unless already_set_up
13
- end
14
-
15
11
  def setup_class
16
12
  setup_callback
17
13
  setup_constants
@@ -6,14 +6,12 @@ module GirFFI
6
6
  # Implements building post-processing statements for return values of
7
7
  # callbacks.
8
8
  class CallbackReturnValueBuilder < BaseArgumentBuilder
9
- def is_relevant?
10
- !is_void_return_value? && !arginfo.skip?
9
+ def relevant?
10
+ !void_return_value? && !arginfo.skip?
11
11
  end
12
12
 
13
13
  def capture_variable_name
14
- if is_relevant?
15
- @capture_variable_name ||= new_variable
16
- end
14
+ @capture_variable_name ||= new_variable if relevant?
17
15
  end
18
16
 
19
17
  def post_converted_name
@@ -25,17 +23,15 @@ module GirFFI
25
23
  end
26
24
 
27
25
  def return_value_name
28
- if is_relevant?
29
- post_converted_name unless array_arg
30
- end
26
+ post_converted_name if has_return_value_name?
31
27
  end
32
28
 
33
29
  def post_conversion
34
30
  if has_post_conversion?
35
31
  if type_info.flattened_tag == :object
36
- [ "#{post_converted_name} = #{post_convertor.conversion}.to_ptr" ]
32
+ ["#{post_converted_name} = #{post_convertor.conversion}.to_ptr"]
37
33
  else
38
- [ "#{post_converted_name} = #{post_convertor.conversion}" ]
34
+ ["#{post_converted_name} = #{post_convertor.conversion}"]
39
35
  end
40
36
  else
41
37
  []
@@ -52,9 +48,13 @@ module GirFFI
52
48
  @post_convertor ||= RubyToCConvertor.new(type_info, capture_variable_name)
53
49
  end
54
50
 
55
- def is_void_return_value?
51
+ def void_return_value?
56
52
  specialized_type_tag == :void && !type_info.pointer?
57
53
  end
54
+
55
+ def has_return_value_name?
56
+ relevant? && !array_arg
57
+ end
58
58
  end
59
59
  end
60
60
  end
@@ -6,10 +6,8 @@ module GirFFI
6
6
  # triggered by a missing constant in the parent namespace. The
7
7
  # constant will be attached to the appropriate namespace module.
8
8
  class ConstantBuilder < BaseTypeBuilder
9
- private
10
-
11
- def instantiate_class
12
- @klass = optionally_define_constant namespace_module, @classname do
9
+ def build_class
10
+ @klass ||= optionally_define_constant namespace_module, @classname do
13
11
  info.value
14
12
  end
15
13
  end
@@ -20,14 +20,8 @@ module GirFFI
20
20
  }.flatten
21
21
  end
22
22
 
23
- def instantiate_class
24
- @enum = optionally_define_constant klass, :Enum do
25
- lib.enum(enum_sym, value_spec)
26
- end
27
- setup_class unless already_set_up
28
- end
29
-
30
23
  def setup_class
24
+ setup_ffi_enum
31
25
  klass.extend superclass
32
26
  setup_constants
33
27
  stub_methods
@@ -38,6 +32,12 @@ module GirFFI
38
32
  @klass ||= get_or_define_module namespace_module, @classname
39
33
  end
40
34
 
35
+ def setup_ffi_enum
36
+ @enum = optionally_define_constant klass, :Enum do
37
+ lib.enum(enum_sym, value_spec)
38
+ end
39
+ end
40
+
41
41
  def setup_inspect
42
42
  klass.instance_eval <<-EOS
43
43
  def self.inspect
@@ -6,12 +6,24 @@ module GirFFI
6
6
  # arguments are not part of the introspected signature, but their
7
7
  # presence is indicated by the 'throws' attribute of the function.
8
8
  class ErrorArgumentBuilder < BaseArgumentBuilder
9
- def pre
10
- [ "#{callarg} = FFI::MemoryPointer.new(:pointer).write_pointer nil" ]
9
+ def method_argument_name
10
+ nil
11
11
  end
12
12
 
13
- def post
14
- [ "GirFFI::ArgHelper.check_error(#{callarg})" ]
13
+ def return_value_name
14
+ nil
15
+ end
16
+
17
+ def capture_variable_name
18
+ nil
19
+ end
20
+
21
+ def pre_conversion
22
+ ["#{call_argument_name} = FFI::MemoryPointer.new(:pointer).write_pointer nil"]
23
+ end
24
+
25
+ def post_conversion
26
+ ["GirFFI::ArgHelper.check_error(#{call_argument_name})"]
15
27
  end
16
28
  end
17
29
  end
@@ -27,11 +27,7 @@ module GirFFI
27
27
  end
28
28
 
29
29
  def setup_setter
30
- container_class.class_eval setter_def if is_writable_field?
31
- end
32
-
33
- def is_writable_field?
34
- info.writable?
30
+ container_class.class_eval setter_def if info.writable?
35
31
  end
36
32
 
37
33
  def getter_def
@@ -43,7 +39,7 @@ module GirFFI
43
39
  <<-CODE.reset_indentation
44
40
  def #{info.name}
45
41
  #{field_ptr} = @struct.to_ptr + #{info.offset}
46
- #{typed_ptr} = GirFFI::InOutPointer.new(#{field_type_tag_or_class.inspect}, #{field_ptr})
42
+ #{typed_ptr} = GirFFI::InOutPointer.new(#{field_type_tag_or_class}, #{field_ptr})
47
43
  #{builder.capture_variable_name} = #{typed_ptr}.to_value
48
44
  #{builder.post_conversion.join("\n")}
49
45
  #{builder.return_value_name}
@@ -60,21 +56,17 @@ module GirFFI
60
56
  <<-CODE.reset_indentation
61
57
  def #{info.name}= #{builder.method_argument_name}
62
58
  #{field_ptr} = @struct.to_ptr + #{info.offset}
63
- #{typed_ptr} = GirFFI::InOutPointer.new(#{field_type_tag_or_class.inspect}, #{field_ptr})
59
+ #{typed_ptr} = GirFFI::InOutPointer.new(#{field_type_tag_or_class}, #{field_ptr})
64
60
  #{builder.pre_conversion.join("\n ")}
65
- #{typed_ptr}.set_value #{builder.callarg}
61
+ #{typed_ptr}.set_value #{builder.call_argument_name}
66
62
  end
67
63
  CODE
68
64
  end
69
65
 
70
66
  private
71
67
 
72
- def struct_class
73
- container_class::Struct
74
- end
75
-
76
68
  def field_type_tag_or_class
77
- @field_type_tag_or_class ||= info.field_type.tag_or_class
69
+ @field_type_tag_or_class ||= info.field_type.tag_or_class.inspect
78
70
  end
79
71
 
80
72
  def container_class
@@ -89,10 +81,6 @@ module GirFFI
89
81
  @container_info ||= info.container
90
82
  end
91
83
 
92
- def field_symbol
93
- @info.name.to_sym
94
- end
95
-
96
84
  def field_type
97
85
  @field_type ||= @info.field_type
98
86
  end