class Objc2swiftAssistant::Objc2SwiftBlockSignature
Attributes
arguments[RW]
block_converter[RW]
return_type[RW]
Public Class Methods
new( block_converter )
click to toggle source
# File lib/objc2swift_assistant/objc_2_swift_block_conversion.rb, line 38 def initialize( block_converter ) @block_converter = block_converter end
Public Instance Methods
arg_for_objc_str( arg_str )
click to toggle source
# File lib/objc2swift_assistant/objc_2_swift_block_conversion.rb, line 100 def arg_for_objc_str( arg_str ) argument = ObjCBlockParameter.new() argument.from_declaration( arg_str ) argument end
from_argument_type( arg_type )
click to toggle source
# File lib/objc2swift_assistant/objc_2_swift_block_conversion.rb, line 50 def from_argument_type( arg_type ) if arg_type.count('^') > 1 failure = "Cannot convert nested Block: #{arg_type}" return "String /*#{failure}*/", failure else m = arg_type.match( /(?<return_type>[^\(]*)\s*\(\s*\^\s*\)\s*\((?<arg_string>.*)\)/ ) if m.nil? failure = "Cannot match block: #{arg_type}" return "String /*#{failure}*/", failure else objc_return_type = m[ 'return_type' ].strip! @return_type = @block_converter.type_converter.swift_type_for_objc_type( objc_return_type ) arg_string = m[ 'arg_string' ] arg_strings = arg_string.nil? ? [] : arg_string.split( ',' ) @arguments = arg_strings.map do |arg_str| arg_for_objc_str( arg_str.strip ) end end end end
from_components( return_type_str, arg_strings )
click to toggle source
# File lib/objc2swift_assistant/objc_2_swift_block_conversion.rb, line 42 def from_components( return_type_str, arg_strings ) @return_type = @block_converter.type_converter.swift_type_for_objc_type( return_type_str ) @arguments = arg_strings.map do |arg_str| arg_for_objc_str( arg_str.strip ) end end
from_property_type( prop_type )
click to toggle source
# File lib/objc2swift_assistant/objc_2_swift_block_conversion.rb, line 96 def from_property_type( prop_type ) end
swift_declaration( full=true )
click to toggle source
# File lib/objc2swift_assistant/objc_2_swift_block_conversion.rb, line 73 def swift_declaration( full=true ) swift_args = @arguments.map do |arg| if arg.param_name.nil? str = "#{arg.param_type}" else str = "#{arg.param_name}: #{arg.param_type}" end str end sig = "(( #{swift_args.join( ', ' )} )" if full || !return_type.nil? if return_type.nil? sig += " -> ())" if return_type.nil? else sig += " -> #{return_type})" end else sig += " -> #{return_type})" unless return_type.nil? end sig end