Class: GirFFI::Builders::VFuncBuilder

Inherits:
GirFFI::BaseTypeBuilder show all
Defined in:
lib/gir_ffi/builders/vfunc_builder.rb

Overview

Implements the creation of a class representing the implementation of a vfunc. This class will be able to turn a proc into an FFI::Function that can serve as such an implementation in C.

Instance Attribute Summary

Attributes inherited from GirFFI::BaseTypeBuilder

#info

Instance Method Summary collapse

Methods inherited from GirFFI::BaseTypeBuilder

#build_class, #initialize

Methods included from GirFFI::BuilderHelper

#const_defined_for, #get_or_define_class, #get_or_define_module, #optionally_define_constant

Constructor Details

This class inherits a constructor from GirFFI::BaseTypeBuilder

Instance Method Details

#argument_typesObject



48
49
50
# File 'lib/gir_ffi/builders/vfunc_builder.rb', line 48

def argument_types
  @argument_types ||= info.argument_ffi_types.unshift(receiver_type_info.to_ffitype)
end

#container_classObject



40
41
42
# File 'lib/gir_ffi/builders/vfunc_builder.rb', line 40

def container_class
  @container_class ||= Builder.build_class(container_info)
end

#container_infoObject



44
45
46
# File 'lib/gir_ffi/builders/vfunc_builder.rb', line 44

def container_info
  @container_info ||= info.container
end

#instantiate_classObject



14
15
16
17
18
19
20
# File 'lib/gir_ffi/builders/vfunc_builder.rb', line 14

def instantiate_class
  unless already_set_up
    setup_constants
    klass.class_eval mapping_method_definition
  end
  klass
end

#klassObject



22
23
24
# File 'lib/gir_ffi/builders/vfunc_builder.rb', line 22

def klass
  @klass ||= get_or_define_class container_class, @classname, CallbackBase
end

#mapping_method_definitionObject



26
27
28
29
30
31
32
33
34
# File 'lib/gir_ffi/builders/vfunc_builder.rb', line 26

def mapping_method_definition
  arg_infos = info.args

  receiver_info = ReceiverArgumentInfo.new(receiver_type_info)

  MappingMethodBuilder.for_vfunc(receiver_info,
                                 arg_infos,
                                 info.return_type).method_definition
end

#receiver_type_infoObject



36
37
38
# File 'lib/gir_ffi/builders/vfunc_builder.rb', line 36

def receiver_type_info
  ReceiverTypeInfo.new(container_info)
end

#return_typeObject



52
53
54
# File 'lib/gir_ffi/builders/vfunc_builder.rb', line 52

def return_type
  @return_type ||= info.return_ffi_type
end