Sha256: 8b7be901266771d5cb32176610ee6333830edf9aa6e2fe8ebd847e2df94cf08e
Contents?: true
Size: 1.12 KB
Versions: 6
Compression:
Stored size: 1.12 KB
Contents
require 'gir_ffi/builders/argument_builder_collection' require 'gir_ffi/builders/method_template' require 'gir_ffi/builders/null_return_value_builder' module GirFFI module Builders # Implements the creation of a Ruby constructor definition out of a # GIR IFunctionInfo. class ConstructorBuilder def initialize(info) @info = info return_value_builder = NullReturnValueBuilder.new arg_builders = ArgumentBuilderCollection.new(return_value_builder, []) @template = MethodTemplate.new(self, arg_builders) end def method_definition @template.method_definition end def singleton_method? true end def method_name @info.safe_name end def method_arguments ['*args'] end def preparation ['obj = allocate'] end def invocation "obj.__send__ #{initializer_name.to_sym.inspect}, #{method_arguments.join(', ')}" end def result ['obj'] end private def initializer_name @info.safe_name.sub(/^new/, 'initialize') end end end end
Version data entries
6 entries across 6 versions & 1 rubygems