Class: GirFFI::Builders::RubyToCConvertor
- Inherits:
-
Object
- Object
- GirFFI::Builders::RubyToCConvertor
- Defined in:
- lib/gir_ffi/builders/ruby_to_c_convertor.rb
Overview
Builder that generates code to convert values from Ruby to C. Used by argument builders.
Instance Method Summary collapse
- #conversion ⇒ Object
- #conversion_arguments(name) ⇒ Object
-
#initialize(type_info, argument_name, ownership_transfer: nil) ⇒ RubyToCConvertor
constructor
A new instance of RubyToCConvertor.
Constructor Details
#initialize(type_info, argument_name, ownership_transfer: nil) ⇒ RubyToCConvertor
Returns a new instance of RubyToCConvertor.
8 9 10 11 12 |
# File 'lib/gir_ffi/builders/ruby_to_c_convertor.rb', line 8 def initialize(type_info, argument_name, ownership_transfer: nil) @type_info = type_info @argument_name = argument_name @ownership_transfer = ownership_transfer end |
Instance Method Details
#conversion ⇒ Object
14 15 16 17 |
# File 'lib/gir_ffi/builders/ruby_to_c_convertor.rb', line 14 def conversion args = conversion_arguments @argument_name "#{@type_info.argument_class_name}.#{conversion_method}(#{args})" end |
#conversion_arguments(name) ⇒ Object
19 20 21 |
# File 'lib/gir_ffi/builders/ruby_to_c_convertor.rb', line 19 def conversion_arguments(name) @type_info.extra_conversion_arguments.map(&:inspect).push(name).join(", ") end |