Class: Objc2swiftAssistant::ObjC2SwiftPropertyConverter
- Inherits:
-
ObjC2SwiftCodeConverter
- Object
- FailableProcessingElement
- ObjC2SwiftCodeConverter
- Objc2swiftAssistant::ObjC2SwiftPropertyConverter
- Defined in:
- lib/objc2swift_assistant/objc_2_swift.rb
Instance Attribute Summary collapse
-
#access_control_state ⇒ Object
Returns the value of attribute access_control_state.
-
#class_converter ⇒ Object
Returns the value of attribute class_converter.
-
#declaration_region ⇒ Object
Returns the value of attribute declaration_region.
-
#getter_method_converter ⇒ Object
Returns the value of attribute getter_method_converter.
-
#property_name ⇒ Object
Returns the value of attribute property_name.
-
#protocol_get_set_spec ⇒ Object
Must be set if part of a protocol definition.
-
#protocol_optional_state ⇒ Object
Returns the value of attribute protocol_optional_state.
-
#setter_method_converter ⇒ Object
Returns the value of attribute setter_method_converter.
Attributes inherited from ObjC2SwiftCodeConverter
#configuration, #file_converter, #marks
Attributes inherited from FailableProcessingElement
Instance Method Summary collapse
- #check_method_for_association(method_converter) ⇒ Object
- #generate(generated_class, configuration, dry_run) ⇒ Object
-
#initialize(class_converter, property_name, configuration) ⇒ ObjC2SwiftPropertyConverter
constructor
A new instance of ObjC2SwiftPropertyConverter.
- #prepare ⇒ Object
Methods inherited from ObjC2SwiftCodeConverter
#add_mark_region, #cannonical_source_file_path, #company_name, #emit_original_bodies, #emit_original_signatures, #emit_unconverted_content, #omit_file
Methods inherited from FailableProcessingElement
#add_error, #add_warning, #has_errors, #initiailize
Constructor Details
#initialize(class_converter, property_name, configuration) ⇒ ObjC2SwiftPropertyConverter
Returns a new instance of ObjC2SwiftPropertyConverter.
679 680 681 682 683 684 685 686 687 |
# 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 |
Instance Attribute Details
#access_control_state ⇒ Object
Returns the value of attribute access_control_state.
676 677 678 |
# File 'lib/objc2swift_assistant/objc_2_swift.rb', line 676 def access_control_state @access_control_state end |
#class_converter ⇒ Object
Returns the value of attribute class_converter.
669 670 671 |
# File 'lib/objc2swift_assistant/objc_2_swift.rb', line 669 def class_converter @class_converter end |
#declaration_region ⇒ Object
Returns the value of attribute declaration_region.
671 672 673 |
# File 'lib/objc2swift_assistant/objc_2_swift.rb', line 671 def declaration_region @declaration_region end |
#getter_method_converter ⇒ Object
Returns the value of attribute getter_method_converter.
672 673 674 |
# File 'lib/objc2swift_assistant/objc_2_swift.rb', line 672 def getter_method_converter @getter_method_converter end |
#property_name ⇒ Object
Returns the value of attribute property_name.
670 671 672 |
# File 'lib/objc2swift_assistant/objc_2_swift.rb', line 670 def property_name @property_name end |
#protocol_get_set_spec ⇒ Object
Must be set if part of a protocol definition
674 675 676 |
# File 'lib/objc2swift_assistant/objc_2_swift.rb', line 674 def protocol_get_set_spec @protocol_get_set_spec end |
#protocol_optional_state ⇒ Object
Returns the value of attribute protocol_optional_state.
677 678 679 |
# File 'lib/objc2swift_assistant/objc_2_swift.rb', line 677 def protocol_optional_state @protocol_optional_state end |
#setter_method_converter ⇒ Object
Returns the value of attribute setter_method_converter.
673 674 675 |
# File 'lib/objc2swift_assistant/objc_2_swift.rb', line 673 def setter_method_converter @setter_method_converter end |
Instance Method Details
#check_method_for_association(method_converter) ⇒ Object
692 693 694 695 696 697 698 699 700 |
# 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) ⇒ Object
702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 |
# 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 ⇒ Object
689 690 |
# File 'lib/objc2swift_assistant/objc_2_swift.rb', line 689 def prepare end |