class Objc2swiftAssistant::ObjC2SwiftPropertyConverter

Attributes

access_control_state[RW]
class_converter[RW]
declaration_region[RW]
getter_method_converter[RW]
property_name[RW]
protocol_get_set_spec[RW]
protocol_optional_state[RW]
setter_method_converter[RW]

Public Class Methods

new( class_converter, property_name, configuration ) click to toggle source
# File lib/objc2swift_assistant/objc_2_swift.rb, line 679
def initialize( class_converter, property_name, configuration )
  super( class_converter.file_converter, configuration )
  @class_converter = class_converter
  @property_name = property_name
  @protocol_get_set_spec = nil

  @access_control_state = nil
  @protocol_optional_state = nil
end

Public Instance Methods

check_method_for_association( method_converter ) click to toggle source
# File lib/objc2swift_assistant/objc_2_swift.rb, line 692
def check_method_for_association( method_converter )
  if Objc2swiftAssistant::is_getter_method_name( property_name, method_converter.swift_name )
    @getter_method_converter = method_converter
    method_converter.owning_property = self
  elsif Objc2swiftAssistant::is_setter_method_name( property_name, method_converter.swift_name )
    @setter_method_converter = method_converter
    method_converter.owning_property = self
  end
end
generate( generated_class, configuration, dry_run ) click to toggle source
# File lib/objc2swift_assistant/objc_2_swift.rb, line 702
def generate( generated_class, configuration, dry_run )
  if @declaration_region.is_block_property
    block_signature = configuration.block_converter.block_sig_for_components( @declaration_region.block_return_type,  @declaration_region.block_args )
    declaration_string = block_signature.swift_declaration( true )
    generated = SwiftGenerator::SwiftBlockProperty.new( generated_class, @property_name, declaration_string, :optional )
  else
    type_symbol = configuration.type_mapper.swift_type_for_objc_type( @declaration_region.type_name ).to_sym
    mutability = @declaration_region.is_pointer ? :var : :let
    # puts( "NYI: mutability" )
    generated = SwiftGenerator::SwiftProperty.new( generated_class, @property_name, type_symbol, :optional )
  end

  generated.protocol_get_set_spec = @protocol_get_set_spec unless @protocol_get_set_spec.nil?     # Used in protocol declarations

  unless @getter_method_converter.nil?
    generated.getter_body = Objc2swiftAssistant::prepare_method_body_lines( @getter_method_converter.implementation_region.unmatched_lines || [] )
  end

  unless @setter_method_converter.nil?
    generated.setter_body = Objc2swiftAssistant::prepare_method_body_lines( @setter_method_converter.implementation_region.unmatched_lines || [] )
  end

  generated.access_control_modifiers = class_converter.make_modifiers( access_control:@access_control_state,
                                                                             optional:@protocol_optional_state )
end
prepare() click to toggle source
# File lib/objc2swift_assistant/objc_2_swift.rb, line 689
def prepare
end