class GirFFI::Builders::PropertyBuilder
Creates property getter and setter code for a given IPropertyInfo.
Public Class Methods
new(property_info)
click to toggle source
# File lib/gir_ffi/builders/property_builder.rb, line 64 def initialize(property_info) @info = property_info end
Public Instance Methods
build()
click to toggle source
# File lib/gir_ffi/builders/property_builder.rb, line 68 def build setup_getter setup_setter if setting_allowed end
container_defines_getter_method?()
click to toggle source
# File lib/gir_ffi/builders/property_builder.rb, line 79 def container_defines_getter_method? container_info.find_instance_method getter_name end
getter_def()
click to toggle source
# File lib/gir_ffi/builders/property_builder.rb, line 87 def getter_def PropertyGetterBuilder.new(@info, getter_builder).method_definition end
setter_def()
click to toggle source
# File lib/gir_ffi/builders/property_builder.rb, line 91 def setter_def converting_setter_def end
setup_getter()
click to toggle source
# File lib/gir_ffi/builders/property_builder.rb, line 73 def setup_getter return if container_defines_getter_method? container_class.class_eval getter_def, __FILE__, __LINE__ end
setup_setter()
click to toggle source
# File lib/gir_ffi/builders/property_builder.rb, line 83 def setup_setter container_class.class_eval setter_def, __FILE__, __LINE__ end
Private Instance Methods
argument_info()
click to toggle source
# File lib/gir_ffi/builders/property_builder.rb, line 134 def argument_info @argument_info ||= FieldArgumentInfo.new("value", type_info) end
container_class()
click to toggle source
# File lib/gir_ffi/builders/property_builder.rb, line 138 def container_class @container_class ||= container_module.const_get(container_info.safe_name) end
container_info()
click to toggle source
TODO: Inject container_info
on initialization
# File lib/gir_ffi/builders/property_builder.rb, line 147 def container_info @container_info ||= @info.container end
container_module()
click to toggle source
# File lib/gir_ffi/builders/property_builder.rb, line 142 def container_module @container_module ||= Object.const_get(container_info.safe_namespace) end
converting_setter_def()
click to toggle source
# File lib/gir_ffi/builders/property_builder.rb, line 103 def converting_setter_def <<~CODE def #{setter_name} value #{setter_builder.pre_conversion.join("\n")} set_property("#{property_name}", #{setter_builder.call_argument_name}) end CODE end
getter_builder()
click to toggle source
# File lib/gir_ffi/builders/property_builder.rb, line 97 def getter_builder @getter_builder ||= PropertyReturnValueBuilder.new(VariableNameGenerator.new, argument_info) end
getter_name()
click to toggle source
# File lib/gir_ffi/builders/property_builder.rb, line 122 def getter_name @info.getter_name end
property_name()
click to toggle source
# File lib/gir_ffi/builders/property_builder.rb, line 118 def property_name @info.name end
setter_builder()
click to toggle source
# File lib/gir_ffi/builders/property_builder.rb, line 112 def setter_builder @setter_builder ||= PropertyArgumentBuilder.new(VariableNameGenerator.new, argument_info) end
setter_name()
click to toggle source
# File lib/gir_ffi/builders/property_builder.rb, line 126 def setter_name @info.setter_name end
setting_allowed()
click to toggle source
# File lib/gir_ffi/builders/property_builder.rb, line 151 def setting_allowed @info.writeable? && !@info.construct_only? end
type_info()
click to toggle source
# File lib/gir_ffi/builders/property_builder.rb, line 130 def type_info @type_info ||= @info.property_type end