Class: GirFFI::Builders::VFuncBuilder
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. The class will be namespaced inside class defining the vfunc.
Instance Attribute Summary
#info
Instance Method Summary
collapse
#build_class, #initialize
#get_or_define_class, #get_or_define_module, #optionally_define_constant
Instance Method Details
#argument_ffi_types ⇒ Object
51
52
53
54
|
# File 'lib/gir_ffi/builders/vfunc_builder.rb', line 51
def argument_ffi_types
@argument_ffi_types ||= info.argument_ffi_types.
unshift(receiver_type_info.to_callback_ffitype)
end
|
#container_class ⇒ Object
43
44
45
|
# File 'lib/gir_ffi/builders/vfunc_builder.rb', line 43
def container_class
@container_class ||= Builder.build_class(container_info)
end
|
#container_info ⇒ Object
47
48
49
|
# File 'lib/gir_ffi/builders/vfunc_builder.rb', line 47
def container_info
@container_info ||= info.container
end
|
#instantiate_class ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/gir_ffi/builders/vfunc_builder.rb', line 15
def instantiate_class
unless already_set_up
setup_constants
klass.class_eval mapping_method_definition
end
klass
end
|
#klass ⇒ Object
23
24
25
|
# File 'lib/gir_ffi/builders/vfunc_builder.rb', line 23
def klass
@klass ||= get_or_define_class container_class, @classname, CallbackBase
end
|
#mapping_method_definition ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/gir_ffi/builders/vfunc_builder.rb', line 27
def mapping_method_definition
arg_infos = info.args
arg_infos << ErrorArgumentInfo.new if info.throws?
receiver_info = ReceiverArgumentInfo.new receiver_type_info
return_value_info = ReturnValueInfo.new info.return_type
MappingMethodBuilder.for_vfunc(receiver_info,
arg_infos,
return_value_info).method_definition
end
|
#receiver_type_info ⇒ Object
39
40
41
|
# File 'lib/gir_ffi/builders/vfunc_builder.rb', line 39
def receiver_type_info
ReceiverTypeInfo.new(container_info)
end
|
#return_ffi_type ⇒ Object
56
57
58
|
# File 'lib/gir_ffi/builders/vfunc_builder.rb', line 56
def return_ffi_type
@return_ffi_type ||= info.return_ffi_type
end
|