Class: Objc2swiftAssistant::ObjC2SwiftProtocolConverter

Inherits:
ObjC2SwiftClassConverter show all
Defined in:
lib/objc2swift_assistant/objc_2_swift.rb

Instance Attribute Summary

Attributes inherited from ObjC2SwiftClassConverter

#class_name, #extension_converter, #super_class

Attributes inherited from ObjC2SwiftClassLikeConverter

#implementation_region, #interface_region, #methods_by_signature, #properties_by_name

Attributes inherited from ObjC2SwiftCodeConverter

#configuration, #file_converter, #marks

Attributes inherited from FailableProcessingElement

#error_messages

Instance Method Summary collapse

Methods inherited from ObjC2SwiftClassConverter

#all_methods, #all_properties, #generate

Methods inherited from ObjC2SwiftClassLikeConverter

#has_errors, #method_for_signature, #process_new_property_converter, #property_for_name

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(file_converter, protocol_name, configuration) ⇒ ObjC2SwiftProtocolConverter

Returns a new instance of ObjC2SwiftProtocolConverter.



454
455
456
457
458
# File 'lib/objc2swift_assistant/objc_2_swift.rb', line 454

def initialize( file_converter, protocol_name, configuration )
  super( file_converter, protocol_name, configuration )
  # super( file_converter, class_name )
  # @extension_region = nil
end

Instance Method Details

#make_generator_class_object(generator_defs, file_name) ⇒ Object



460
461
462
463
# File 'lib/objc2swift_assistant/objc_2_swift.rb', line 460

def make_generator_class_object( generator_defs, file_name )
  extends_list = @interface_region.extends || []
  SwiftGenerator::SwiftProtocol.new( generator_defs, class_name, extends_list, file_name:file_name.to_s, characteristics:[] )
end

#make_modifiers(access_control: nil, optional: nil) ⇒ Object



477
478
479
480
481
482
483
484
485
486
487
# File 'lib/objc2swift_assistant/objc_2_swift.rb', line 477

def make_modifiers( access_control:nil, optional:nil )
  access_qualifiers = super( access_control:access_control, optional:optional )

  return access_qualifiers if optional.nil?

  if optional == :optional
    access_qualifiers << 'optional'
  end

  access_qualifiers
end

#prepareObject



465
466
467
468
469
470
471
472
473
474
475
# File 'lib/objc2swift_assistant/objc_2_swift.rb', line 465

def prepare( )
  super( )
  all_properties.each do |property_converter|

    if property_converter.declaration_region.modifiers.include?( 'readonly' )   #declaration_region must exist
      property_converter.protocol_get_set_spec = "{ get }"
    else
      property_converter.protocol_get_set_spec = "{ get set }"
    end
  end
end