module Objc2swiftAssistant

require_relative 'file_sets' require_relative 'recognizers/recognizer_keys' require_relative 'objc_2_swift_type_mapping' require_relative 'objc_2_swift_block_conversion'

Constants

ALL_CONFIG_KEYS
AT_DIRECTIVE_KEY
CATEGORY_DECLARARATION_KEY
CATEGORY_DECLARATION_REGEX
CATEGORY_IMPLEMENTATION_KEY
CATEGORY_IMPLEMENTATION_REGEX
CAT_EXT_DECLARARATION_KEY
CLASS_IMPLEMENTATION_KEY
CLASS_INTERFACE_KEY
COMPANY_NAME_KEY
DIRECTIVE_REGEX
EMIT_ORIGINAL_BODIES_KEY
EMIT_ORIGINAL_SIGNATURES_KEY
EMIT_UNCONVERTED_CONTENT_KEY
ENUM_DECLARATION_KEY
EXTENSION_DECLARARATION_KEY
LOG_LEVELS_BY_NAME
LOG_LEVEL_DEBUG
LOG_LEVEL_ERRORS
LOG_LEVEL_NONE
LOG_LEVEL_VERBOSE
LOG_LEVEL_WARNINGS
METHOD_DECLARATION_KEY
METHOD_IMPLEMENTATION_KEY
METHOD_INDETERMINATE_KEY
OMIT_FILE_KEY
PATH_KEY
PRAGMA_MARK_KEY
PRAGMA_MARK_REGEX
PROPERTY_DECLARATION_KEY
PROTOCOL_DECLARATION_KEY
SUBDIR_KEY
VERSION

Public Class Methods

cleanup_method_body_lines( file_lines ) click to toggle source
# File lib/objc2swift_assistant/objc_2_swift.rb, line 11
def cleanup_method_body_lines( file_lines )
  cleaned_up = []
  file_lines.each do |line|
    no_trailing = line.rstrip
    next if no_trailing.strip == '@end'
    cleaned_up << no_trailing if no_trailing.length > 0
  end

  cleaned_up
end
de_comment_line( line ) click to toggle source
# File lib/objc2swift_assistant/code_recognizer.rb, line 6
def de_comment_line( line )
  new_line = line
  m = line.match( /^(?<uncommented>.*)\/\/(?<comment>.*)/ )
  unless m.nil?
    new_line = m[ 'uncommented' ].strip
  end

  return new_line
end
de_comment_lines( lines ) click to toggle source
# File lib/objc2swift_assistant/code_recognizer.rb, line 17
def de_comment_lines( lines )
  # Line Comments
  return lines.map do |line|
    Objc2swiftAssistant::de_comment_line( line )
  end
end
is_getter_method_name( property_name, method_name ) click to toggle source
# File lib/objc2swift_assistant/code_recognizer.rb, line 25
def is_getter_method_name( property_name, method_name )
  #TODO: add boolean rules
  return property_name == method_name
end
is_setter_method_name( property_name, method_name ) click to toggle source
# File lib/objc2swift_assistant/code_recognizer.rb, line 32
def is_setter_method_name( property_name, method_name )
  setter_name = "set" + property_name[0, 1].upcase + property_name[1..-1]
  return method_name == setter_name
end
prepare_class_header_lines( file_lines ) click to toggle source
# File lib/objc2swift_assistant/objc_2_swift.rb, line 23
def prepare_class_header_lines( file_lines )
  cleaned_up = []
  file_lines.each do |line|
    no_trailing = line.rstrip
    cleaned_up << '// ' + no_trailing if no_trailing.length > 0
  end

  cleaned_up
end
prepare_method_body_lines( lines ) click to toggle source
# File lib/objc2swift_assistant/objc_2_swift.rb, line 34
def prepare_method_body_lines( lines )
  raw_body_lines = cleanup_method_body_lines( lines )
  body_lines = raw_body_lines.map do |line|
    '// ' + line
  end

  body_lines
end

Public Instance Methods

description() click to toggle source
# File lib/objc2swift_assistant/recognizers/pragma_mark_recognizer.rb, line 32
def description()
  if @is_block_property
    return generic_description( "Block Property: prop_name=#{@prop_name} block_return_type=#{@block_return_type} block_args=#{@block_args}" )
  else
    return generic_description( "type_name=#{@type_name} is_pointer=#{@is_pointer} prop_name=#{@prop_name}" )
  end
end

Private Instance Methods

cleanup_method_body_lines( file_lines ) click to toggle source
# File lib/objc2swift_assistant/objc_2_swift.rb, line 11
def cleanup_method_body_lines( file_lines )
  cleaned_up = []
  file_lines.each do |line|
    no_trailing = line.rstrip
    next if no_trailing.strip == '@end'
    cleaned_up << no_trailing if no_trailing.length > 0
  end

  cleaned_up
end
de_comment_line( line ) click to toggle source
# File lib/objc2swift_assistant/code_recognizer.rb, line 6
def de_comment_line( line )
  new_line = line
  m = line.match( /^(?<uncommented>.*)\/\/(?<comment>.*)/ )
  unless m.nil?
    new_line = m[ 'uncommented' ].strip
  end

  return new_line
end
de_comment_lines( lines ) click to toggle source
# File lib/objc2swift_assistant/code_recognizer.rb, line 17
def de_comment_lines( lines )
  # Line Comments
  return lines.map do |line|
    Objc2swiftAssistant::de_comment_line( line )
  end
end
is_getter_method_name( property_name, method_name ) click to toggle source
# File lib/objc2swift_assistant/code_recognizer.rb, line 25
def is_getter_method_name( property_name, method_name )
  #TODO: add boolean rules
  return property_name == method_name
end
is_setter_method_name( property_name, method_name ) click to toggle source
# File lib/objc2swift_assistant/code_recognizer.rb, line 32
def is_setter_method_name( property_name, method_name )
  setter_name = "set" + property_name[0, 1].upcase + property_name[1..-1]
  return method_name == setter_name
end
prepare_class_header_lines( file_lines ) click to toggle source
# File lib/objc2swift_assistant/objc_2_swift.rb, line 23
def prepare_class_header_lines( file_lines )
  cleaned_up = []
  file_lines.each do |line|
    no_trailing = line.rstrip
    cleaned_up << '// ' + no_trailing if no_trailing.length > 0
  end

  cleaned_up
end
prepare_method_body_lines( lines ) click to toggle source
# File lib/objc2swift_assistant/objc_2_swift.rb, line 34
def prepare_method_body_lines( lines )
  raw_body_lines = cleanup_method_body_lines( lines )
  body_lines = raw_body_lines.map do |line|
    '// ' + line
  end

  body_lines
end