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 63 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 67 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 78 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 86 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 90 def setter_def converting_setter_def end
setup_getter()
click to toggle source
# File lib/gir_ffi/builders/property_builder.rb, line 72 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 82 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 133 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 137 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 146 def container_info @container_info ||= @info.container end
container_module()
click to toggle source
# File lib/gir_ffi/builders/property_builder.rb, line 141 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 102 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 96 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 121 def getter_name @info.getter_name end
property_name()
click to toggle source
# File lib/gir_ffi/builders/property_builder.rb, line 117 def property_name @info.name end
setter_builder()
click to toggle source
# File lib/gir_ffi/builders/property_builder.rb, line 111 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 125 def setter_name @info.setter_name end
setting_allowed()
click to toggle source
# File lib/gir_ffi/builders/property_builder.rb, line 150 def setting_allowed @info.writeable? && !@info.construct_only? end
type_info()
click to toggle source
# File lib/gir_ffi/builders/property_builder.rb, line 129 def type_info @type_info ||= @info.property_type end