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

#invocation, #method_arguments, #method_definition, #preparation

Constructor Details

#initialize(info) ⇒ FunctionBuilder

Returns a new instance of FunctionBuilder.



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

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

Instance Method Details

#function_call_argumentsObject



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

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

#method_nameObject



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

def method_name
  @info.safe_name
end

#resultObject



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

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

#singleton_method?Boolean

Returns:



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

def singleton_method?
  !@info.method?
end