Sha256: b660cf84de20f47b74bfb3df6f5bbec03498854abe18bc8a9cfa1eae32e8a585
Contents?: true
Size: 1.82 KB
Versions: 6
Compression:
Stored size: 1.82 KB
Contents
require_relative "version" module Objc2swiftAssistant class Objc2SwiftTypeMapper attr_accessor :mappings_by_swift_type attr_accessor :mappings_by_objc_type def initialize( ) @mappings_by_swift_type = {} @mappings_by_objc_type = {} #initialize default mappings map_types( :BOOL, :Bool, 'false' ) map_types( :int, :Int, '0' ) map_types( :NSUInteger, :UInt, '0') map_types( :CGFloat, :Float, '0.0' ) map_types( :id, :AnyObject?, '0.0' ) map_types( :void, nil, nil ) end def map_types( objc_type_symbol, swift_type_symbol, swift_default_value ) mapping = Objc2SwiftTypeMapping.new( objc_type_symbol, swift_type_symbol, swift_default_value) set_mapping( mapping ) mapping end def set_mapping( mapping ) @mappings_by_swift_type[ mapping.swift_type_symbol ] = mapping @mappings_by_objc_type[ mapping.objc_type_symbol ] = mapping end def mapping_for_objc_type( objc_type_string ) @mappings_by_objc_type[ objc_type_string.to_sym ] end def swift_type_for_objc_type( objc_type_str ) mapping = mapping_for_objc_type( objc_type_str ) mapping.nil? ? objc_type_str : mapping.swift_type_string end end class Objc2SwiftTypeMapping attr_accessor :objc_type_symbol attr_accessor :swift_type_symbol attr_accessor :swift_default_value def initialize( objc_type_symbol, swift_type_symbol, swift_default_value ) @objc_type_symbol = objc_type_symbol @swift_type_symbol = swift_type_symbol @swift_default_value = swift_default_value end def swift_type_string @swift_type_symbol.nil? ? nil : @swift_type_symbol.to_s end end @@type_mapping = Objc2SwiftTypeMapper.new() end
Version data entries
6 entries across 6 versions & 1 rubygems