Class: GirFFI::Builders::MarshallingMethodBuilder
- Inherits:
-
Object
- Object
- GirFFI::Builders::MarshallingMethodBuilder
- Defined in:
- lib/gir_ffi/builders/marshalling_method_builder.rb
Overview
Implements the creation mapping method for a signal handler. This method converts arguments from C to Ruby, and the result from Ruby to C.
TODO: Inherit from BaseMethodBuilder
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(receiver_info, argument_infos, return_value_info) ⇒ MarshallingMethodBuilder
constructor
A new instance of MarshallingMethodBuilder.
- #invocation ⇒ Object
- #method_arguments ⇒ Object
- #method_definition ⇒ Object
- #method_name ⇒ Object
- #preparation ⇒ Object
- #result ⇒ Object
- #singleton_method? ⇒ Boolean
Constructor Details
#initialize(receiver_info, argument_infos, return_value_info) ⇒ MarshallingMethodBuilder
Returns a new instance of MarshallingMethodBuilder.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/gir_ffi/builders/marshalling_method_builder.rb', line 19 def initialize(receiver_info, argument_infos, return_value_info) receiver_builder = make_argument_builder receiver_info argument_builders = argument_infos.map { |arg| make_argument_builder arg } return_value_builder = ClosureReturnValueBuilder.new(variable_generator, return_value_info) @argument_builder_collection = ArgumentBuilderCollection.new(return_value_builder, argument_builders, receiver_builder: receiver_builder) @template = MethodTemplate.new(self, @argument_builder_collection) end |
Class Method Details
.for_signal(receiver_info, argument_infos, return_value_info) ⇒ Object
15 16 17 |
# File 'lib/gir_ffi/builders/marshalling_method_builder.rb', line 15 def self.for_signal(receiver_info, argument_infos, return_value_info) new receiver_info, argument_infos, return_value_info end |
Instance Method Details
#invocation ⇒ Object
51 52 53 |
# File 'lib/gir_ffi/builders/marshalling_method_builder.rb', line 51 def invocation "wrap(closure.to_ptr).invoke_block(#{call_argument_list})" end |
#method_arguments ⇒ Object
39 40 41 |
# File 'lib/gir_ffi/builders/marshalling_method_builder.rb', line 39 def method_arguments %w(closure return_value param_values _invocation_hint _marshal_data) end |
#method_definition ⇒ Object
31 32 33 |
# File 'lib/gir_ffi/builders/marshalling_method_builder.rb', line 31 def method_definition @template.method_definition end |
#method_name ⇒ Object
35 36 37 |
# File 'lib/gir_ffi/builders/marshalling_method_builder.rb', line 35 def method_name 'marshaller' end |
#preparation ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/gir_ffi/builders/marshalling_method_builder.rb', line 43 def preparation if param_names.size == 1 ["#{param_names.first} = param_values.first.get_value_plain"] else ["#{param_names.join(', ')} = param_values.map(&:get_value_plain)"] end end |
#result ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/gir_ffi/builders/marshalling_method_builder.rb', line 55 def result if (name = @argument_builder_collection.return_value_name) ["return_value.set_value #{name}"] else [] end end |
#singleton_method? ⇒ Boolean
63 64 65 |
# File 'lib/gir_ffi/builders/marshalling_method_builder.rb', line 63 def singleton_method? true end |