Class: Objc2swiftAssistant::ObjC2SwiftClassConverter
- Inherits:
-
ObjC2SwiftClassLikeConverter
- Object
- FailableProcessingElement
- ObjC2SwiftCodeConverter
- ObjC2SwiftClassLikeConverter
- Objc2swiftAssistant::ObjC2SwiftClassConverter
- Defined in:
- lib/objc2swift_assistant/objc_2_swift.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#class_name ⇒ Object
Returns the value of attribute class_name.
-
#extension_converter ⇒ Object
Returns the value of attribute extension_converter.
-
#super_class ⇒ Object
Returns the value of attribute 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
Instance Method Summary collapse
- #all_methods ⇒ Object
- #all_properties ⇒ Object
- #generate(generator_defs, file_name, configuration, dry_run) ⇒ Object
-
#initialize(file_converter, class_name, configuration) ⇒ ObjC2SwiftClassConverter
constructor
A new instance of ObjC2SwiftClassConverter.
- #make_generator_class_object(generator_defs, file_name) ⇒ Object
- #make_modifiers(access_control: nil, optional: nil) ⇒ Object
- #prepare ⇒ Object
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, class_name, configuration) ⇒ ObjC2SwiftClassConverter
Returns a new instance of ObjC2SwiftClassConverter.
359 360 361 362 |
# File 'lib/objc2swift_assistant/objc_2_swift.rb', line 359 def initialize( file_converter, class_name, configuration ) super( file_converter, class_name, configuration ) @extension_region = nil end |
Instance Attribute Details
#class_name ⇒ Object
Returns the value of attribute class_name.
355 356 357 |
# File 'lib/objc2swift_assistant/objc_2_swift.rb', line 355 def class_name @class_name end |
#extension_converter ⇒ Object
Returns the value of attribute extension_converter.
357 358 359 |
# File 'lib/objc2swift_assistant/objc_2_swift.rb', line 357 def extension_converter @extension_converter end |
#super_class ⇒ Object
Returns the value of attribute super_class.
356 357 358 |
# File 'lib/objc2swift_assistant/objc_2_swift.rb', line 356 def super_class @super_class end |
Instance Method Details
#all_methods ⇒ Object
384 385 386 387 388 389 390 |
# File 'lib/objc2swift_assistant/objc_2_swift.rb', line 384 def all_methods methods = @methods_by_signature.values.clone methods << @extension_region.methods_by_signature.all_values unless @extension_region.nil? # Categories are handled as seperate entities # @category_regions_by_name.inject( methods ) { |m, (k, v)| m << v.methods_by_signature; m } methods end |
#all_properties ⇒ Object
392 393 394 395 396 397 398 |
# File 'lib/objc2swift_assistant/objc_2_swift.rb', line 392 def all_properties properties = @properties_by_name.values.clone properties << @extension_region.properties_by_name.all_values unless @extension_region.nil? # Categories are handled as seperate entities # @category_regions_by_name.inject( properties ) { |p, (k, v)| p << v.properties_by_name; p } properties end |
#generate(generator_defs, file_name, configuration, dry_run) ⇒ Object
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
# File 'lib/objc2swift_assistant/objc_2_swift.rb', line 400 def generate( generator_defs, file_name, configuration, dry_run ) generated_class = make_generator_class_object( generator_defs, file_name ) generated_class.source_file.company_name = configuration.company_name( cannonical_source_file_path.to_s ) unless cannonical_source_file_path.nil? if ! @interface_region.nil? && emit_unconverted_content() generated_class.top_inner_comment_block = Objc2swiftAssistant::prepare_class_header_lines( @interface_region.root_header ) end properties_by_name.each do | _, property | property.generate( generated_class, configuration, dry_run ) end methods_by_signature.each do | _, method | method.generate( generated_class, configuration, dry_run ) end end |
#make_generator_class_object(generator_defs, file_name) ⇒ Object
417 418 419 420 421 422 423 424 425 426 427 |
# File 'lib/objc2swift_assistant/objc_2_swift.rb', line 417 def make_generator_class_object( generator_defs, file_name ) @configuration.log_verbose( "------- #{@interface_region.implements}" ) unless @interface_region.nil? if @interface_region.nil? implements_list =[] else implements_list = @interface_region.super_class.nil? ? [] : [@interface_region.super_class] implements_list << @interface_region.implements unless @interface_region.implements.nil? || @interface_region.implements.length == 0 end SwiftGenerator::SwiftClass.new( generator_defs, class_name, implements_list, file_name:file_name.to_s, characteristics:[] ) end |
#make_modifiers(access_control: nil, optional: nil) ⇒ Object
429 430 431 432 433 |
# File 'lib/objc2swift_assistant/objc_2_swift.rb', line 429 def make_modifiers( access_control:nil, optional:nil ) return [] if access_control.nil? return [access_control.to_s] end |
#prepare ⇒ Object
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
# File 'lib/objc2swift_assistant/objc_2_swift.rb', line 364 def prepare methods = all_methods properties = all_properties methods.each do |method_converter| method_converter.compute_swift_name end properties.each do |property_converter| methods.each do |method_converter| property_converter.check_method_for_association(method_converter) end property_converter.prepare end methods.each do |method_converter| method_converter.prepare end end |