Class: GirFFI::Builders::FunctionBuilder

Inherits:
BaseMethodBuilder show all
Defined in:
lib/gir_ffi/builders/function_builder.rb

Overview

Implements the creation of a Ruby function definition out of a GIR IFunctionInfo.

Instance Method Summary collapse

Methods inherited from BaseMethodBuilder

#argument_builder_collection, #argument_builders, #error_argument, #invocation, #method_arguments, #method_definition, #preparation, #receiver_builder, #return_value_builder, #return_value_info, #template, #variable_generator

Constructor Details

#initialize(info) ⇒ FunctionBuilder

Returns a new instance of FunctionBuilder.



10
11
12
# File 'lib/gir_ffi/builders/function_builder.rb', line 10

def initialize(info)
  super(info, ReturnValueBuilder)
end

Instance Method Details

#function_call_argumentsObject



30
31
32
33
34
# File 'lib/gir_ffi/builders/function_builder.rb', line 30

def function_call_arguments
  ca = argument_builder_collection.call_argument_names.dup
  ca.unshift receiver_call_argument if @info.method?
  ca
end

#method_nameObject



14
15
16
# File 'lib/gir_ffi/builders/function_builder.rb', line 14

def method_name
  @info.safe_name
end

#resultObject



18
19
20
21
22
23
24
# File 'lib/gir_ffi/builders/function_builder.rb', line 18

def result
  if argument_builder_collection.has_return_values?
    ["return #{argument_builder_collection.return_value_names.join(', ')}"]
  else
    []
  end
end

#singleton_method?Boolean

Returns:



26
27
28
# File 'lib/gir_ffi/builders/function_builder.rb', line 26

def singleton_method?
  !@info.method?
end