├── .gitignore ├── LICENSE.md ├── README.md ├── Source ├── Aliases.swift ├── Array.Java.swift ├── Array.swift ├── Bit.swift ├── Bool.swift ├── CG_Extensions.swift ├── Character.swift ├── Codable.swift ├── Collections.swift ├── Commandline.swift ├── Compose.swift ├── Dictionary.Java.swift ├── Dictionary.swift ├── Dispatch.swift ├── Errors.swift ├── Foundation_Extension.swift ├── Functions.swift ├── Functions_ObjC.swift ├── INonLazySequence_Extensions.swift ├── Index_Protocols.swift ├── Integer_Extensions.swift ├── Integer_Protocols.swift ├── LiteralConvertibles.swift ├── MemoryLayout.swift ├── Mirror.swift ├── NSArray_Extensions.swift ├── Nougat.swift ├── Number_Constructors.swift ├── Object_Extensions.swift ├── Operators.swift ├── Pointers.swift ├── Protocols.swift ├── Range.swift ├── Sequence_Extensions.swift ├── Sequence_Functions.swift ├── Sequence_Protocols.swift ├── Set.swift ├── Silver.elements ├── Silver.sln ├── String.Encoding.swift ├── String.Views.swift ├── String.swift ├── String_Extensions.swift ├── Swift.Cooper.elements ├── Swift.Echoes.Standard.elements ├── Swift.Echoes.elements ├── Swift.Island.Android.elements ├── Swift.Island.Darwin.iOS.elements ├── Swift.Island.Darwin.macOS.elements ├── Swift.Island.Darwin.tvOS.elements ├── Swift.Island.Darwin.watchOS.elements ├── Swift.Island.Linux.elements ├── Swift.Island.WebAssembly.elements ├── Swift.Island.Windows.elements ├── Swift.Shared.elements ├── Swift.Shared.projitems ├── Swift.Toffee.iOS.elements ├── Swift.Toffee.macOS.elements ├── Swift.Toffee.tvOS.elements ├── Swift.Toffee.watchOS.elements ├── SwiftBaseLibrary.licenses ├── SwiftBaseLibrary.sln ├── UnicodeScalar_Extensions.swift ├── Unmanaged.swift ├── __AssemblyInfo.swift └── __Internal.swift └── Tests ├── Dictionary.swift ├── Program.swift ├── Range.swift ├── Swift.Tests.elements └── Swift.Tests.sln /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | obj 3 | *.user 4 | *.cache 5 | *.suo 6 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014-2015, RemObjects Software. All rights reserved. 2 | Written by marc hoffman (mh@remobjects.com) 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SwiftBaseLibrary 2 | 3 | The Swift Base Library is a small library that can be optionally used in Swift projects compiled with the [RemObjects Silver](http://elementscompiler.com/silver) compiler. It provides some of the core types, classes and functions that, while not part of the Swift language spec per se, are commonly used in Swift apps (and provided in a similar Swift Base Library in Apple's implementation). 4 | 5 | This includes types such as the Swift-native [array](http://docs.elementscompiler.com/API/StandardTypes/Arrays) and [dictionary](http://docs.elementscompiler.com/API/StandardTypes/DictionarySwift) types, and base functions like `println()`. 6 | 7 | The Swift Base Library ships precompiled with the [Elements](http://elementscompiler.com) compiler. New projects created with one of the RemObjects Silver project templates will automatically have a reference to the library, but if you are adding Swift files to a project that started out with a different language, you can add a reference to your projects via the [Add References](http://docs.elementscompiler.com/Projects/References) dialog in Fire or Visual Studio, where it should show automatically. 8 | 9 | The library will be called `Swift.dll` on .NET, `libSwift.fx` on Cocoa and `swift.jar` on Java and Android. 10 | 11 | The code for the this library is open source and available under a liberal license. We appreciate contributions. 12 | 13 | ## See Also 14 | 15 | * [RemObjects Silver Homepage](http://www.elementscompiler.com/silver/) 16 | * [RemObjects Silver Docs](http://docs.elementscompiler.com/Silver/) 17 | * [Swift Base Library API Reference](http://docs.elementscompiler.com/API/SwiftBaseLibrary) on docs.elementscompiler.com 18 | -------------------------------------------------------------------------------- /Source/Aliases.swift: -------------------------------------------------------------------------------- 1 | #if DARWIN 2 | public typealias NSObject = Foundation.Object 3 | #else 4 | public typealias NSObject = Object 5 | #endif 6 | 7 | #if CLR || JAVA 8 | public typealias Int = Int64 9 | public typealias UInt = UInt64 10 | #elseif ISLAND 11 | #if CPU64 12 | public typealias Int = Int64 13 | public typealias UInt = UInt64 14 | #elseif CPU32 15 | public typealias Int = Int32 16 | public typealias UInt = UInt32 17 | #else 18 | #hint Unexpected bitness 19 | public typealias Int = Int64 20 | public typealias UInt = UInt64 21 | #endif 22 | #elseif COCOA 23 | public typealias Int = NSInteger 24 | public typealias UInt = NSUInteger 25 | #endif 26 | public typealias Int8 = SByte 27 | public typealias UInt8 = Byte 28 | 29 | public typealias IntMax = Int64 30 | public typealias UIntMax = UInt64 31 | 32 | public typealias Bool = Boolean 33 | 34 | public typealias UnicodeScalar = UTF32Char 35 | public typealias UTF16Char = Char // UInt16 36 | public typealias UTF32Char = UInt32 37 | #if !COCOA && !ISLAND 38 | public typealias AnsiChar = Byte 39 | // Cocoa and Island already have AnsiChar 40 | #endif 41 | public typealias UTF8Char = Byte 42 | 43 | public typealias StaticString = NativeString 44 | 45 | public typealias Float = Single 46 | public typealias Float32 = Single 47 | public typealias Float64 = Double 48 | 49 | public typealias Any = protocol<> //Dynamic; 50 | public typealias AnyObject = protocol<> //Dynamic; 51 | #if CLR 52 | public typealias AnyClass = System.`Type` 53 | #elseif COCOA 54 | public typealias AnyClass = rtl.Class 55 | #elseif JAVA 56 | public typealias AnyClass = java.lang.Class 57 | #endif 58 | 59 | #if DARWIN 60 | public typealias Selector = SEL 61 | public typealias NSObjectProtocol = INSObject 62 | public typealias INSObjectProtocol = INSObject 63 | #endif 64 | 65 | /* more obscure aliases */ 66 | 67 | public typealias BooleanLiteralType = Bool 68 | public typealias CBool = Bool 69 | public typealias CChar = Int8 70 | public typealias CChar16 = UInt16 71 | public typealias CChar32 = UnicodeScalar 72 | public typealias CDouble = Double 73 | public typealias CFloat = Float 74 | public typealias CInt = Int32 75 | public typealias CLong = Int 76 | public typealias CLongLong = Int64 77 | 78 | #if !JAVA 79 | // UnsafeMutablePointer and UnsafePointer are defined by the compiler 80 | public typealias UnsafeMutableBufferPointer = UnsafeMutablePointer 81 | public typealias UnsafeBufferPointer = UnsafePointer 82 | public typealias UnsafeMutableRawPointer = UnsafeMutablePointer 83 | public typealias UnsafeRawPointer = UnsafePointer 84 | public typealias UnsafeMutableRawBufferPointer = UnsafeMutablePointer 85 | public typealias UnsafeRawBufferPointer = UnsafePointer 86 | public typealias OpaquePointer = UnsafePointer 87 | #endif 88 | 89 | public typealias CShort = Int16 90 | public typealias CSignedChar = Int8 91 | public typealias CUnsignedChar = UInt8 92 | public typealias CUnsignedInt = UInt32 93 | public typealias CUnsignedLong = UInt 94 | public typealias CUnsignedLongLong = UInt64 95 | public typealias CUnsignedShort = UInt16 96 | public typealias CWideChar = UnicodeScalar 97 | public typealias ExtendedGraphemeClusterType = NativeString 98 | public typealias FloatLiteralType = Double 99 | public typealias IntegerLiteralType = Int 100 | public typealias StringLiteralType = NativeString 101 | public typealias UWord = UInt16 102 | public typealias UnicodeScalarType = NativeString 103 | //public typealias Void = () // defined by Compiler 104 | public typealias Word = Int -------------------------------------------------------------------------------- /Source/Array.Java.swift: -------------------------------------------------------------------------------- 1 | #if JAVA 2 | public extension Swift.Array : java.util.List { 3 | public func size() -> Int32 { 4 | return count 5 | } 6 | public func isEmpty() -> Bool { 7 | return isEmpty 8 | } 9 | public func contains(_ arg1: Object!) -> Bool { 10 | return list.contains(arg1) 11 | } 12 | @inline(__always) 13 | public func toArray(_ arg1: T![]) -> T![] { 14 | return platformList.toArray(arg1) 15 | } 16 | @inline(__always) 17 | public func toArray() -> Object![] { 18 | return platformList.toArray() 19 | } 20 | mutating func add(_ arg1: Int32, _ arg2: T!) { 21 | makeUnique() 22 | list.add(arg1, arg2) 23 | } 24 | public mutating func add(_ arg1: T!) -> Bool { 25 | makeUnique() 26 | return list.add(arg1) 27 | } 28 | public mutating func remove(_ arg1: Int32) -> T! { 29 | makeUnique() 30 | return list.remove(arg1) 31 | } 32 | public mutating func remove(_ arg1: Object!) -> Bool { 33 | makeUnique() 34 | return list.remove(arg1) 35 | } 36 | public func containsAll(_ arg1: Collection!) -> Bool { 37 | return list.containsAll(arg1) 38 | } 39 | public mutating func addAll(_ arg1: Int32, _ arg2: Collection!) -> Bool { 40 | makeUnique() 41 | return list.addAll(arg1, arg2) 42 | } 43 | public mutating func addAll(_ arg1: Collection!) -> Bool { 44 | makeUnique() 45 | return list.addAll(arg1) 46 | } 47 | public mutating func removeAll(_ arg1: Collection!) -> Bool { 48 | makeUnique() 49 | return list.removeAll(arg1) 50 | } 51 | public mutating func retainAll(_ arg1: Collection!) -> Bool { 52 | makeUnique() 53 | return list.retainAll(arg1) 54 | } 55 | public mutating func replaceAll(_ arg1: java.util.function.UnaryOperator!) { 56 | makeUnique() 57 | list.replaceAll(arg1) 58 | } 59 | public mutating func sort(_ arg1: Comparator!) { 60 | makeUnique() 61 | list.sort(arg1) 62 | } 63 | public mutating func clear() { 64 | removeAll() 65 | } 66 | public override func equals(_ arg1: Object!) -> Bool { 67 | if let a = arg1 as? [T] { 68 | return a == self 69 | } 70 | return false 71 | } 72 | public override func hashCode() -> Int32 { 73 | return list.hashCode() 74 | } 75 | public func indexOf(_ arg1: Object!) -> Int32 { 76 | return list.indexOf(arg1) 77 | } 78 | public func lastIndexOf(_ arg1: Object!) -> Int32 { 79 | return list.lastIndexOf(arg1) 80 | } 81 | public func listIterator(_ arg1: Int32) -> ListIterator! { 82 | return platformList.listIterator(arg1) 83 | } 84 | public func listIterator() -> ListIterator! { 85 | return platformList.listIterator() 86 | } 87 | public func subList(_ arg1: Int32, _ arg2: Int32) -> java.util.List! { 88 | return self[arg1...arg2] 89 | } 90 | public func spliterator() -> Spliterator! { 91 | return platformList.spliterator() 92 | } 93 | public func `get`(_ arg1: Int32) -> T { 94 | return self[arg1] 95 | } 96 | public mutating func `set`(_ arg1: Int32, _ value: T!) -> T { 97 | let old = self[arg1] 98 | self[arg1] = value 99 | return old 100 | } 101 | } 102 | #endif -------------------------------------------------------------------------------- /Source/Bit.swift: -------------------------------------------------------------------------------- 1 | /// A `RandomAccessIndexType` that has two possible values. Used as 2 | /// the `Index` type for `CollectionOfOne`. 3 | public enum Bit { //: Int32, ForwardIndexType { //, Comparable, RandomAccessIndexType, _Reflectable { // 74094: Silver: interfaces on enums 4 | 5 | //associatedtype typealias /*Distance*/ = Int // 74095: Silver: cant use type alias in an enum 6 | 7 | case Zero = 0, One = 1 8 | 9 | /// Returns the next consecutive value after `self`. 10 | /// 11 | /// - Requires: `self == .Zero`. 12 | public func successor() -> Bit { 13 | precondition(self == .Zero, "Can't increment past one") 14 | return .One 15 | } 16 | 17 | /// Returns the previous consecutive value before `self`. 18 | /// 19 | /// - Requires: `self != .Zero`. 20 | public func predecessor() -> Bit { 21 | precondition(self == .One, "Can't decrement past zero") 22 | return .Zero 23 | } 24 | 25 | //74097: Silver: cant access "rawValue" in enum 26 | /*public func distanceTo(other: Bit) -> Int { 27 | return rawValue.distanceTo(other.rawValue) 28 | } 29 | 30 | public func advancedBy(n: Int/*Distance*/) -> Bit { 31 | return rawValue.advancedBy(n) > 0 ? One : Zero 32 | }*/ 33 | 34 | //#if COCOA 35 | //override var debugDescription: NativeString! { 36 | //#else 37 | public var debugDescription: NativeString { 38 | //#endif 39 | var result = "Bit(" 40 | switch self { 41 | case .Zero: result += ".Zero" 42 | case .One: result += ".One" 43 | } 44 | result += ")" 45 | return result 46 | } 47 | } 48 | 49 | @warn_unused_result 50 | public func == (lhs: Bit, rhs: Bit) -> Bool { 51 | return lhs.rawValue == rhs.rawValue 52 | } 53 | 54 | @warn_unused_result 55 | public func < (lhs: Bit, rhs: Bit) -> Bool { 56 | return lhs.rawValue < rhs.rawValue 57 | } 58 | 59 | /* 60 | extension Bit : IntegerArithmeticType { 61 | static func _withOverflow( 62 | intResult: Int, overflow: Bool 63 | ) -> (Bit, overflow: Bool) { 64 | if let bit = Bit(rawValue: intResult) { 65 | return (bit, overflow: overflow) 66 | } else { 67 | let bitRaw = intResult % 2 + (intResult < 0 ? 2 : 0) 68 | let bit = Bit(rawValue: bitRaw)! 69 | return (bit, overflow: true) 70 | } 71 | } 72 | 73 | /// Add `lhs` and `rhs`, returning a result and a `Bool` that is 74 | /// true iff the operation caused an arithmetic overflow. 75 | public static func addWithOverflow( 76 | lhs: Bit, _ rhs: Bit 77 | ) -> (Bit, overflow: Bool) { 78 | return _withOverflow(Int.addWithOverflow(lhs.rawValue, rhs.rawValue)) 79 | } 80 | 81 | /// Subtract `lhs` and `rhs`, returning a result and a `Bool` that is 82 | /// true iff the operation caused an arithmetic overflow. 83 | public static func subtractWithOverflow( 84 | lhs: Bit, _ rhs: Bit 85 | ) -> (Bit, overflow: Bool) { 86 | return _withOverflow(Int.subtractWithOverflow(lhs.rawValue, rhs.rawValue)) 87 | } 88 | 89 | /// Multiply `lhs` and `rhs`, returning a result and a `Bool` that is 90 | /// true iff the operation caused an arithmetic overflow. 91 | public static func multiplyWithOverflow( 92 | lhs: Bit, _ rhs: Bit 93 | ) -> (Bit, overflow: Bool) { 94 | return _withOverflow(Int.multiplyWithOverflow(lhs.rawValue, rhs.rawValue)) 95 | } 96 | 97 | /// Divide `lhs` and `rhs`, returning a result and a `Bool` that is 98 | /// true iff the operation caused an arithmetic overflow. 99 | public static func divideWithOverflow( 100 | lhs: Bit, _ rhs: Bit 101 | ) -> (Bit, overflow: Bool) { 102 | return _withOverflow(Int.divideWithOverflow(lhs.rawValue, rhs.rawValue)) 103 | } 104 | 105 | /// Divide `lhs` and `rhs`, returning the remainder and a `Bool` that is 106 | /// true iff the operation caused an arithmetic overflow. 107 | public static func remainderWithOverflow( 108 | lhs: Bit, _ rhs: Bit 109 | ) -> (Bit, overflow: Bool) { 110 | return _withOverflow(Int.remainderWithOverflow(lhs.rawValue, rhs.rawValue)) 111 | } 112 | 113 | /// Represent this number using Swift's widest native signed integer 114 | /// type. 115 | public func toIntMax() -> IntMax { 116 | return IntMax(rawValue) 117 | } 118 | } 119 | */ -------------------------------------------------------------------------------- /Source/Bool.swift: -------------------------------------------------------------------------------- 1 | extension Bool { 2 | 3 | public mutating func toggle() { 4 | self = !self 5 | } 6 | 7 | } -------------------------------------------------------------------------------- /Source/CG_Extensions.swift: -------------------------------------------------------------------------------- 1 | #if COCOA 2 | import CoreGraphics 3 | 4 | public extension CGPoint { 5 | 6 | public init() { 7 | return CoreGraphics.CGPointZero 8 | } 9 | 10 | public init(x: CGFloat, y: CGFloat) { 11 | return CGPointMake(x, y) 12 | } 13 | 14 | public static var zero: CGPoint { return CoreGraphics.CGPointZero } 15 | } 16 | 17 | public extension CGSize { 18 | 19 | public init() { 20 | return CoreGraphics.CGSizeZero 21 | } 22 | 23 | public init(width: CGFloat, height: CGFloat) { 24 | return CGSizeMake(width, height) 25 | } 26 | 27 | public static var zero: CGSize { return CoreGraphics.CGSizeZero } 28 | } 29 | 30 | public extension CGRect { 31 | 32 | public init() { 33 | return CoreGraphics.CGRectZero 34 | } 35 | 36 | public init(origin: CGPoint, size: CGSize) { 37 | return CGRectMake(origin.x, origin.y, size.width, size.height) 38 | } 39 | 40 | public init(x: CGFloat, y: CGFloat, width: CGFloat, height: CGFloat) { 41 | return CGRectMake(x, y, width, height) 42 | } 43 | 44 | public var minX: CGFloat { return size.width >= 0 ? origin.x : origin.x-size.width } 45 | public var minY: CGFloat { return size.height >= 0 ? origin.y : origin.y-size.height } 46 | public var maxX: CGFloat { return size.width >= 0 ? origin.x+size.width : origin.x } 47 | public var maxY: CGFloat { return size.height >= 0 ? origin.y+size.height : origin.y } 48 | 49 | public var x: CGFloat { return origin.x } 50 | public var y: CGFloat { return origin.y } 51 | public var width: CGFloat { return size.width } 52 | public var height: CGFloat { return size.height } 53 | 54 | public static var zero: CGRect { return CoreGraphics.CGRectZero } 55 | public static var null: CGRect { return CoreGraphics.CGRectNull } 56 | public static var infinite: CGRect { return CoreGraphics.CGRectInfinite } 57 | } 58 | #endif -------------------------------------------------------------------------------- /Source/Character.swift: -------------------------------------------------------------------------------- 1 | public struct Character { 2 | 3 | internal let nativeStringValue: NativeString 4 | 5 | @ToString public func ToString() -> NativeString { 6 | return nativeStringValue 7 | } 8 | 9 | public static func __implicit(_ char: Char) -> Character { 10 | return Character(nativeStringValue: char) 11 | } 12 | 13 | public static func __implicit(_ string: String) -> Character { 14 | if string.characters.count != 1 { // not super efficient 15 | throw Exception("Cannot cast string '\(string)' to Character") 16 | } 17 | return Character(nativeStringValue: string) 18 | } 19 | 20 | internal func toHexString() -> NativeString { 21 | if length(nativeStringValue) == 1 { 22 | return UInt32(nativeStringValue[0]).toHexString(length: 4) 23 | } else if length(nativeStringValue) > 1 { 24 | var result = "" 25 | var currentSurrogate: Char = "\0" 26 | for i in 0 ..< length(nativeStringValue) { 27 | 28 | let c = nativeStringValue[i] 29 | let c2 = UInt32(c) 30 | var newChar: NativeString? = nil 31 | if c2 <= 0x0D7FF || c2 > 0x00E000 { 32 | if currentSurrogate != "\0" { 33 | throw Exception("Invalid surrogate pair at index \(i)") 34 | } 35 | newChar = UInt32(nativeStringValue[i]).toHexString(length: 4) 36 | } else if c2 >= 0x00D800 && c2 <= 0x00DBFF { 37 | if currentSurrogate != "\0" { 38 | throw Exception("Invalid surrogate pair at index \(i)") 39 | } 40 | currentSurrogate = c 41 | } else if c2 >= 0x00DC00 && c2 < 0x00DFFF { 42 | if let surrogate = currentSurrogate { 43 | var code = 0x10000; 44 | code += (surrogate & 0x03FF) << 10; 45 | code += (c & 0x03FF); 46 | newChar = UInt32(code).toHexString(length: 6) 47 | currentSurrogate = "\0" 48 | } else { 49 | throw Exception("Invalid surrogate pair at index \(i)") 50 | } 51 | } 52 | 53 | if let newChar = newChar { 54 | if length(result) > 0 { 55 | result += "-" 56 | } 57 | result += newChar 58 | } 59 | } 60 | return result 61 | } else { 62 | return "0" 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /Source/Collections.swift: -------------------------------------------------------------------------------- 1 |  2 | //74077: Allow GetSequence() to actually be used to implement ISequence 3 | public struct CollectionOfOne /*ICollectionType,*/ { 4 | ///*, ISequence*/ { // 74093: Silver: should not require explicit generic on interfaces in ancestor list 5 | 6 | public typealias Index = Bit 7 | public typealias Distance = Int // should not be needed, if default is provided 8 | 9 | /// Construct an instance containing just `element`. 10 | public init(_ element: Element) { 11 | self.element = element 12 | } 13 | 14 | /// The position of the first element. 15 | public var startIndex: Index { 16 | return .Zero 17 | } 18 | 19 | public var endIndex: Index { 20 | return .One 21 | } 22 | 23 | let element: Element 24 | 25 | public var count: Int { 26 | return 1 27 | } 28 | 29 | // 30 | // Subscripts & Iterators 31 | // 32 | 33 | public subscript(position: Index) -> Element { 34 | precondition(position == .Zero, "Index out of range") 35 | return element 36 | } 37 | 38 | @Sequence 39 | public func GetSequence() -> ISequence { 40 | __yield element 41 | } 42 | 43 | #if TOFFEE && !TOFFEEV2 44 | //public func countByEnumeratingWithState(_ state: UnsafePointer, objects stackbuf: UnsafePointer, count len: NSUInteger) -> NSUInteger { 45 | 46 | //if state.state > 0 { 47 | //return 0; 48 | //} 49 | 50 | //state.itemsPtr = unsafeBitCast(element, Int); 51 | //state.state = 1; 52 | //state.mutationsPtr = unsafeBitCast(self, Int); 53 | //return 1; 54 | //} 55 | #endif 56 | } -------------------------------------------------------------------------------- /Source/Commandline.swift: -------------------------------------------------------------------------------- 1 | internal var __C_ARGC = 0 2 | internal var __C_ARGV: [NativeString]! 3 | public var C_ARGC: Int { get { return __C_ARGC; } } 4 | public var C_ARGV: [NativeString] { get { return __C_ARGV!; } } 5 | 6 | public func `$$setArgV`(_ args: NativeString[]) { 7 | __C_ARGC = length(args); 8 | __C_ARGV = [NativeString](arrayLiteral: args); 9 | } 10 | 11 | #if COCOA 12 | public func __stringArrayToCStringArray(_ arcv: [NativeString]) -> (UnsafePointer)[] { 13 | 14 | var result = UnsafePointer[](arcv.count) 15 | for i in 0 ..< arcv.count { 16 | if arcv[i] != nil { 17 | result[i] = (arcv[i] as! NativeString).UTF8String 18 | } else { 19 | result[i] = nil 20 | } 21 | } 22 | return result 23 | } 24 | #endif 25 | 26 | public enum CommandLine { 27 | public static var argc: Int32 { return __C_ARGC } 28 | // public static var unsafeArgv: UnsafeMutablePointer?> 29 | public static var arguments: [String] { return __C_ARGV } 30 | } -------------------------------------------------------------------------------- /Source/Compose.swift: -------------------------------------------------------------------------------- 1 |  2 | /// The function composition operator is the only user-defined operator that 3 | /// operates on functions. That's why the numeric value of precedence does 4 | /// not matter right now. 5 | infix operator ∘ { associativity left precedence 100 } // The character is U+2218 RING OPERATOR. 6 | 7 | 8 | /// Compose functions. 9 | /// 10 | /// (g ∘ f)(x) == g(f(x)) 11 | /// 12 | /// - Returns: a function that applies ``g`` to the result of applying ``f`` 13 | /// to the argument of the new function. 14 | public func ∘ (g: U -> V, f: T -> U) -> (T -> V) { 15 | return { g(f($0)) } 16 | } 17 | 18 | infix operator ∖ { associativity left precedence 140 } 19 | infix operator ∖= { associativity right precedence 90 assignment } 20 | infix operator ∪ { associativity left precedence 140 } 21 | infix operator ∪= { associativity right precedence 90 assignment } 22 | infix operator ∩ { associativity left precedence 150 } 23 | infix operator ∩= { associativity right precedence 90 assignment } 24 | infix operator ⨁ { associativity left precedence 140 } 25 | infix operator ⨁= { associativity right precedence 90 assignment } 26 | infix operator ∈ { associativity left precedence 130 } 27 | infix operator ∉ { associativity left precedence 130 } 28 | infix operator ⊂ { associativity left precedence 130 } 29 | infix operator ⊄ { associativity left precedence 130 } 30 | infix operator ⊆ { associativity left precedence 130 } 31 | infix operator ⊈ { associativity left precedence 130 } 32 | infix operator ⊃ { associativity left precedence 130 } 33 | infix operator ⊅ { associativity left precedence 130 } 34 | infix operator ⊇ { associativity left precedence 130 } 35 | infix operator ⊉ { associativity left precedence 130 } 36 | 37 | /// - Returns: The relative complement of `lhs` with respect to `rhs`. 38 | public func ∖ >(lhs: Set, rhs: S) -> Set { 39 | return lhs.subtract(rhs) 40 | } 41 | 42 | /// Assigns the relative complement between `lhs` and `rhs` to `lhs`. 43 | public func ∖= >(inout lhs: Set, rhs: S) { 44 | lhs.subtractInPlace(rhs) 45 | } 46 | 47 | /// - Returns: The union of `lhs` and `rhs`. 48 | public func ∪ >(lhs: Set, rhs: S) -> Set { 49 | return lhs.union(rhs) 50 | } 51 | 52 | /// Assigns the union of `lhs` and `rhs` to `lhs`. 53 | public func ∪= >(inout lhs: Set, rhs: S) { 54 | lhs.unionInPlace(rhs) 55 | } 56 | 57 | /// - Returns: The intersection of `lhs` and `rhs`. 58 | public func ∩ >(lhs: Set, rhs: S) -> Set { 59 | return lhs.intersect(rhs) 60 | } 61 | 62 | /// Assigns the intersection of `lhs` and `rhs` to `lhs`. 63 | public func ∩= >(inout lhs: Set, rhs: S) { 64 | lhs.intersectInPlace(rhs) 65 | } 66 | 67 | /// - Returns: A set with elements in `lhs` or `rhs` but not in both. 68 | public func ⨁ >(lhs: Set, rhs: S) -> Set { 69 | return lhs.exclusiveOr(rhs) 70 | } 71 | 72 | /// Assigns to `lhs` the set with elements in `lhs` or `rhs` but not in both. 73 | public func ⨁= >(inout lhs: Set, rhs: S) { 74 | lhs.exclusiveOrInPlace(rhs) 75 | } 76 | 77 | /// - Returns: True if `x` is in the set. 78 | public func ∈ (x: T, rhs: Set) -> Bool { 79 | return rhs.contains(x) 80 | } 81 | 82 | /// - Returns: True if `x` is not in the set. 83 | public func ∉ (x: T, rhs: Set) -> Bool { 84 | return !rhs.contains(x) 85 | } 86 | 87 | /// - Returns: True if `lhs` is a strict subset of `rhs`. 88 | public func ⊂ >(lhs: Set, rhs: S) -> Bool { 89 | return lhs.isStrictSubsetOf(rhs) 90 | } 91 | 92 | /// - Returns: True if `lhs` is not a strict subset of `rhs`. 93 | public func ⊄ >(lhs: Set, rhs: S) -> Bool { 94 | return !lhs.isStrictSubsetOf(rhs) 95 | } 96 | 97 | /// - Returns: True if `lhs` is a subset of `rhs`. 98 | public func ⊆ >(lhs: Set, rhs: S) -> Bool { 99 | return lhs.isSubsetOf(rhs) 100 | } 101 | 102 | /// - Returns: True if `lhs` is not a subset of `rhs`. 103 | public func ⊈ >(lhs: Set, rhs: S) -> Bool { 104 | return !lhs.isSubsetOf(rhs) 105 | } 106 | 107 | /// - Returns: True if `lhs` is a strict superset of `rhs`. 108 | public func ⊃ >(lhs: Set, rhs: S) -> Bool { 109 | return lhs.isStrictSupersetOf(rhs) 110 | } 111 | 112 | /// - Returns: True if `lhs` is not a strict superset of `rhs`. 113 | public func ⊅ >(lhs: Set, rhs: S) -> Bool { 114 | return !lhs.isStrictSupersetOf(rhs) 115 | } 116 | 117 | /// - Returns: True if `lhs` is a superset of `rhs`. 118 | public func ⊇ >(lhs: Set, rhs: S) -> Bool { 119 | return lhs.isSupersetOf(rhs) 120 | } 121 | 122 | /// - Returns: True if `lhs` is not a superset of `rhs`. 123 | public func ⊉ >(lhs: Set, rhs: S) -> Bool { 124 | return !lhs.isSupersetOf(rhs) 125 | } -------------------------------------------------------------------------------- /Source/Dictionary.Java.swift: -------------------------------------------------------------------------------- 1 | #if JAVA 2 | public extension Swift.Dictionary : java.util.Map { 3 | 4 | public func size() -> Int32 { 5 | return dictionary.size() 6 | } 7 | public func isEmpty() -> Bool { 8 | return dictionary.isEmpty() 9 | } 10 | public func containsKey(_ arg1: Object!) -> Bool { 11 | return dictionary.containsKey(arg1) 12 | } 13 | public func containsValue(_ arg1: Object!) -> Bool { 14 | return dictionary.containsValue(arg1) 15 | } 16 | public func `get`(_ arg1: Object!) -> Value! { 17 | return dictionary.`get`(arg1) 18 | } 19 | public mutating func put(_ arg1: Key!, _ arg2: Value!) -> Value! { 20 | makeUnique() 21 | return dictionary.put(arg1, arg2) 22 | } 23 | public mutating func remove(_ arg1: Object!, _ arg2: Object!) -> Bool { 24 | makeUnique() 25 | return dictionary.remove(arg1, arg2) 26 | } 27 | public mutating func remove(_ arg1: Object!) -> Value! { 28 | makeUnique() 29 | return dictionary.remove(arg1) 30 | } 31 | public mutating func putAll(_ arg1: Map!) { 32 | makeUnique() 33 | dictionary.putAll(arg1) 34 | } 35 | public mutating func clear() { 36 | makeUnique() 37 | dictionary.clear() 38 | } 39 | public func keySet() -> java.util.Set! { 40 | return platformDictionary.keySet() 41 | } 42 | public func values() -> Collection! { 43 | return platformDictionary.values() 44 | } 45 | public func entrySet() -> java.util.Set!>! { 46 | return platformDictionary.entrySet() 47 | } 48 | public override func equals(_ arg1: Object!) -> Bool { 49 | return dictionary.equals(arg1) 50 | } 51 | public override func hashCode() -> Int32 { 52 | return dictionary.hashCode() 53 | } 54 | public func getOrDefault(_ arg1: Object!, _ arg2: Value!) -> Value! { 55 | return dictionary.getOrDefault(arg1, arg2) 56 | } 57 | public func forEach(_ arg1: java.util.function.BiConsumer!) { 58 | dictionary.forEach(arg1) 59 | } 60 | public mutating func replaceAll(_ arg1: java.util.function.BiFunction!) { 61 | makeUnique() 62 | dictionary.replaceAll(arg1) 63 | } 64 | public mutating func putIfAbsent(_ arg1: Key!, _ arg2: Value!) -> Value! { 65 | makeUnique() 66 | return dictionary.putIfAbsent(arg1, arg2) 67 | } 68 | public mutating func replace(_ arg1: Key!, _ arg2: Value!) -> Value! { 69 | makeUnique() 70 | return dictionary.replace(arg1, arg2) 71 | } 72 | public mutating func replace(_ arg1: Key!, _ arg2: Value!, _ arg3: Value!) -> Bool { 73 | makeUnique() 74 | return dictionary.replace(arg1, arg2, arg3) 75 | } 76 | public func computeIfAbsent(_ arg1: Key!, _ arg2: java.util.function.Function!) -> Value! { 77 | return dictionary.computeIfAbsent(arg1, arg2) 78 | } 79 | public func computeIfPresent(_ arg1: Key!, _ arg2: java.util.function.BiFunction!) -> Value! { 80 | return dictionary.computeIfPresent(arg1, arg2) 81 | } 82 | public func compute(_ arg1: Key!, _ arg2: java.util.function.BiFunction!) -> Value! { 83 | return dictionary.compute(arg1, arg2) 84 | } 85 | public mutating func merge(_ arg1: Key!, _ arg2: Value!, _ arg3: java.util.function.BiFunction!) -> Value! { 86 | makeUnique() 87 | return dictionary.merge(arg1, arg2, arg3) 88 | } 89 | } 90 | #endif -------------------------------------------------------------------------------- /Source/Dictionary.swift: -------------------------------------------------------------------------------- 1 | #if COCOA 2 | public typealias PlatformDictionary = NSMutableDictionary 3 | public typealias PlatformImmutableDictionary = NSDictionary 4 | #elseif JAVA 5 | public typealias PlatformDictionary = java.util.HashMap 6 | public typealias PlatformImmutableDictionary = PlatformDictionary 7 | #elseif CLR 8 | public typealias PlatformDictionary = System.Collections.Generic.Dictionary 9 | public typealias PlatformImmutableDictionary = PlatformDictionary 10 | #elseif ISLAND 11 | public typealias PlatformDictionary = RemObjects.Elements.System.Dictionary 12 | public typealias PlatformImmutableDictionary = PlatformDictionary 13 | #endif 14 | 15 | // 16 | // 17 | // CAUTION: Magic type name. 18 | // The compiler will map the [:] dictionary syntax to Swift.Dictionaty 19 | // 20 | // 21 | 22 | public struct Dictionary /*: INSFastEnumeration*/ 23 | { 24 | public init(copy original: inout [Key:Value]) { 25 | self.dictionary = original.dictionary 26 | self.unique = false 27 | original.unique = false 28 | } 29 | 30 | public init() { 31 | dictionary = PlatformDictionary() 32 | } 33 | 34 | //public init(items: inout [Key:Value]) { // E59 Duplicate constructor with same signature "init(items var items: [Key:Value])" 35 | public convenience init(items: [Key:Value]) { 36 | var litems = items; 37 | self = Dictionary(copy: &litems) 38 | self.unique = false 39 | makeUnique() // workaorund for not having inout 40 | //items.unique = false 41 | } 42 | 43 | public init(minimumCapacity: Int) { 44 | #if JAVA 45 | dictionary = PlatformDictionary(minimumCapacity) 46 | #elseif CLR 47 | dictionary = PlatformDictionary(minimumCapacity) 48 | #elseif ISLAND 49 | dictionary = PlatformDictionary(minimumCapacity) 50 | #elseif COCOA 51 | dictionary = PlatformDictionary(capacity: minimumCapacity) 52 | #endif 53 | } 54 | 55 | public init(_ dictionary: PlatformImmutableDictionary) { 56 | #if JAVA | CLR | ISLAND 57 | self.dictionary = PlatformDictionary(dictionary) 58 | #elseif COCOA 59 | self.dictionary = dictionary.mutableCopy 60 | #endif 61 | self.unique = false 62 | makeUnique() 63 | } 64 | 65 | #if COCOA 66 | //public init(_ dictionary: NSDictionary) { 67 | //self.dictionary = dictionary.mutableCopy 68 | //} 69 | #endif 70 | 71 | public convenience init(dictionaryLiteral elements: (Key, Value)...) { 72 | init(minimumCapacity: length(elements)) 73 | for e in elements { 74 | self[e[0]] = e[1] 75 | } 76 | } 77 | 78 | // 79 | // Storage 80 | // 81 | 82 | internal var dictionary: PlatformDictionary 83 | internal var unique: Boolean = true 84 | 85 | private mutating func makeUnique() 86 | { 87 | if !unique { 88 | dictionary = platformDictionary // platformDictionary returns a unique new copy 89 | unique = true 90 | } 91 | } 92 | 93 | // 94 | // 95 | // 96 | 97 | @Sequence 98 | public func GetSequence() -> ISequence<(key: Key, value: Value)> { 99 | return DictionaryHelper.Enumerate(dictionary) 100 | } 101 | 102 | // 103 | // Casts 104 | // 105 | 106 | // Cast from/to platform type 107 | 108 | public static func __implicit(_ dictionary: PlatformDictionary) -> [Key:Value] { 109 | return [Key:Value](dictionary) 110 | } 111 | 112 | public static func __implicit(_ dictionary: [Key:Value]) -> PlatformDictionary { 113 | return dictionary.platformDictionary 114 | } 115 | 116 | // Darwin only: cast from/to Cocoa type 117 | 118 | #if DARWIN && !ISLAND 119 | public static func __implicit(_ dictionary: [Key:Value]) -> PlatformImmutableDictionary { 120 | return dictionary.platformDictionary 121 | } 122 | #endif 123 | 124 | // 125 | // Operators 126 | // 127 | 128 | public static func + (lhs: [Key:Value], rhs: [Key:Value]) -> [Key:Value] { 129 | var result = lhs 130 | for k in rhs.keys { 131 | result[k] = rhs[k] 132 | } 133 | return result 134 | } 135 | 136 | public static func == (lhs: [Key:Value], rhs: [Key:Value]) -> Bool { 137 | if lhs.dictionary == rhs.dictionary { 138 | return true 139 | } 140 | guard lhs.keys.count == rhs.keys.count else { 141 | return false 142 | } 143 | 144 | func compare(_ r: Value, _ l: Value) -> Bool { 145 | #if COOPER 146 | return l.equals(r) 147 | #elseif ECHOES 148 | return System.Collections.Generic.EqualityComparer.Default.Equals(l, r) 149 | #elseif ISLAND 150 | return RemObjects.Elements.System.EqualityComparer.Equals(l, r) 151 | #elseif COCOA 152 | return l.isEqual(r) 153 | #endif 154 | return true 155 | } 156 | 157 | for k in lhs.keys { 158 | let l = lhs[k]! 159 | let r = rhs[k] 160 | guard let r = r else { 161 | return false 162 | } 163 | if !compare(l,r) { 164 | return false 165 | } 166 | } 167 | for k in rhs.keys { 168 | let l = lhs[k] 169 | if l == nil { 170 | return false 171 | } 172 | } 173 | return true 174 | } 175 | 176 | public static func != (lhs: [Key:Value], rhs: [Key:Value]) -> Bool { 177 | return !(rhs == lhs) 178 | } 179 | 180 | #if CLR 181 | public override func Equals(_ other: Object!) -> Bool { 182 | guard let other = other as? [Key:Value] else { 183 | return false 184 | } 185 | return self == other 186 | } 187 | #elseif COCOA 188 | public override func isEqual(_ other: Object!) -> Bool { 189 | guard let other = other as? [Key:Value] else { 190 | return false 191 | } 192 | return self == other 193 | } 194 | #endif 195 | 196 | // 197 | // Native Access 198 | // 199 | 200 | public var platformDictionary: PlatformDictionary 201 | { 202 | #if COOPER || ECHOES || ISLAND 203 | return PlatformDictionary(dictionary) 204 | #elseif TOFFEE 205 | return dictionary.mutableCopy() 206 | #endif 207 | } 208 | 209 | // 210 | // Subscripts 211 | // 212 | 213 | public subscript (key: Key) -> Value? { 214 | get { 215 | #if JAVA 216 | if dictionary.containsKey(key) { 217 | return dictionary[key] 218 | } 219 | return nil 220 | #elseif CLR || ISLAND 221 | if dictionary.ContainsKey(key) { 222 | return dictionary[key] 223 | } 224 | return nil 225 | #elseif COCOA 226 | return dictionary[key] 227 | #endif 228 | } 229 | set { 230 | makeUnique() 231 | #if JAVA 232 | if let v = newValue { 233 | dictionary[key] = v 234 | } else { 235 | if dictionary.containsKey(key) { 236 | dictionary.remove(key) 237 | } 238 | } 239 | #elseif CLR || ISLAND 240 | if let v = newValue { 241 | dictionary[key] = v 242 | } else { 243 | if dictionary.ContainsKey(key) { 244 | dictionary.Remove(key) 245 | } 246 | } 247 | #elseif COCOA 248 | if let val = newValue { 249 | dictionary[key] = val 250 | } else { 251 | dictionary.removeObjectForKey(key) 252 | } 253 | #endif 254 | } 255 | } 256 | 257 | public mutating func updateValue(_ value: Value, forKey key: Key) -> Value? { 258 | makeUnique() 259 | #if JAVA 260 | if dictionary.containsKey(key) { 261 | let old = dictionary[key] 262 | dictionary[key] = value 263 | return old 264 | } 265 | return nil 266 | #elseif CLR || ISLAND 267 | if dictionary.ContainsKey(key) { 268 | let old = dictionary[key] 269 | dictionary[key] = value 270 | return old 271 | } 272 | return nil 273 | #elseif COCOA 274 | let old = dictionary[key] 275 | if let val = value { 276 | dictionary[key] = val 277 | } else { 278 | dictionary.removeObjectForKey(key) 279 | } 280 | return old 281 | #endif 282 | } 283 | 284 | public mutating func removeValue(forKey key: Key) -> Value? { 285 | makeUnique() 286 | #if JAVA 287 | if dictionary.containsKey(key) { 288 | return dictionary.remove(key) 289 | } 290 | return nil 291 | #elseif CLR || ISLAND 292 | if dictionary.ContainsKey(key) { 293 | let old = dictionary[key] 294 | dictionary.Remove(key) 295 | return old 296 | } 297 | return nil 298 | #elseif COCOA 299 | let old = dictionary[key] 300 | dictionary.removeObjectForKey(key) 301 | return old 302 | #endif 303 | } 304 | 305 | public mutating func removeAll(keepCapacity: Bool = false) { 306 | dictionary = PlatformDictionary() 307 | unique = true 308 | } 309 | 310 | //public func forEach(_ body: ((key: Key, value: Value)) throws -> Void) rethrows { 311 | //for item in self { 312 | //try body(item) 313 | //} 314 | //} 315 | 316 | public var count: Int { 317 | #if JAVA 318 | return dictionary.keySet().Count() 319 | #elseif CLR 320 | return dictionary.Count() 321 | #elseif ISLAND 322 | return dictionary.Count 323 | #elseif COCOA 324 | return dictionary.count 325 | #endif 326 | } 327 | 328 | public var isEmpty: Bool { 329 | #if JAVA 330 | return dictionary.isEmpty() 331 | #elseif CLR 332 | return dictionary.Count() == 0 333 | #elseif ISLAND 334 | return dictionary.Count == 0 335 | #elseif COCOA 336 | return dictionary.count == 0 337 | #endif 338 | } 339 | 340 | public var keys: ISequence { // we deliberatey return a sequence, not an dictionary, for efficiency and flexibility. 341 | #if JAVA 342 | return dictionary.keySet() 343 | #elseif CLR || ISLAND 344 | return dictionary.Keys 345 | #elseif COCOA 346 | return dictionary.allKeys as! ISequence 347 | #endif 348 | } 349 | 350 | public var values: ISequence { // we deliberatey return a sequence, not an dictionary, for efficiency and flexibility. 351 | #if JAVA 352 | return dictionary.values() 353 | #elseif CLR || ISLAND 354 | return dictionary.Values 355 | #elseif COCOA 356 | return dictionary.allValues as! ISequence 357 | #endif 358 | } 359 | 360 | @ToString 361 | public override func description() -> NativeString { 362 | return dictionary.description 363 | } 364 | } 365 | 366 | #if DARWIN && ISLAND 367 | public extension Swift.Dictionary where Key: NSObject, Value: NSObject { 368 | public static func __implicit(_ dictionary: NSDictionary) -> [Key:Value] { 369 | return PlatformDictionary(dictionary) 370 | } 371 | 372 | public static func __implicit(_ dictionary: [Key:Value]) -> NSDictionary { 373 | return dictionary.dictionary.ToNSDictionary() 374 | } 375 | 376 | public static func __implicit(_ dictionary: [Key:Value]) -> NSMutableDictionary { 377 | return dictionary.dictionary.ToNSMutableDictionary() 378 | } 379 | 380 | // Cocoa only: cast from/to different generic Cocoa type 381 | 382 | public static func __explicit(_ dictionary: NSDictionary) -> [Key:Value] { 383 | return (dictionary as! NSDictionary) as! [Key:Value] 384 | } 385 | 386 | public static func __explicit(_ dictionary: [Key:Value]) -> NSDictionary { 387 | return (dictionary as! NSDictionary) as! NSDictionary 388 | } 389 | 390 | public static func __explicit(_ dictionary: [Key:Value]) -> NSMutableDictionary { 391 | return (dictionary as! NSMutableDictionary) as! NSMutableDictionary 392 | } 393 | } 394 | #endif 395 | 396 | public static class DictionaryHelper { 397 | #if JAVA 398 | public static func Enumerate(_ val: PlatformDictionary) -> ISequence<(Key, Value)> { 399 | for entry in val.entrySet() { 400 | var item: (key: Key, value: Value) = (entry.Key, entry.Value) 401 | __yield item 402 | } 403 | } 404 | #elseif CLR | ISLAND 405 | public static func Enumerate(_ val: PlatformDictionary) -> ISequence<(Key, Value)> { 406 | for entry in val { 407 | var item: (key: Key, value: Value) = (entry.Key, entry.Value) 408 | __yield item 409 | } 410 | } 411 | #elseif COCOA 412 | public static func Enumerate(_ val: PlatformDictionary) -> ISequence<(Key, Value)> { 413 | for entry in val { 414 | var item: (key: Key, value: Value) = (entry, val[entry]?) 415 | __yield item 416 | } 417 | } 418 | #endif 419 | } -------------------------------------------------------------------------------- /Source/Errors.swift: -------------------------------------------------------------------------------- 1 | public typealias Error = Exception 2 | 3 | public enum Result { 4 | case value(Value), error(Error) 5 | } -------------------------------------------------------------------------------- /Source/Foundation_Extension.swift: -------------------------------------------------------------------------------- 1 | #if COCOA 2 | import Foundation 3 | 4 | @inline(always) func NSLocalizedString(_ key: String, comment: String) -> String { 5 | return NSBundle.mainBundle.localizedStringForKey(key, value: "", table: nil) 6 | } 7 | #endif -------------------------------------------------------------------------------- /Source/Functions.swift: -------------------------------------------------------------------------------- 1 | // @inline(__always) public func abs(x) // provied by compiler 2 | 3 | @Conditional("DEBUG") public func assert(_ condition: @autoclosure () -> Bool, _ message: @autoclosure () -> String, file: String = #file, line: UWord = #line) { 4 | if (!condition()) { 5 | fatalError(message, file: file, line: line) 6 | } 7 | } 8 | 9 | @Conditional("DEBUG") public func assertionFailure(_ message: @autoclosure () -> String, file: String = #file, line: UWord = #line) -> Never { 10 | fatalError(message, file: file, line: line) 11 | } 12 | 13 | // we have overloads, instead of default parameters, because otherwise CC will always insert the full signature, 14 | // although the most common use case is to use print() without the extra parameters: 15 | 16 | @inline(__always) public func debugPrint(_ object: Object?) { 17 | print(object, separator: " ", terminator: nil) 18 | } 19 | 20 | @inline(__always) public func debugPrint(_ object: Object?, separator: String) { 21 | print(object, separator: separator, terminator: nil) 22 | } 23 | 24 | @inline(__always) public func debugPrint(_ object: Object?, terminator: String?) { 25 | print(object, separator: " ", terminator: terminator) 26 | } 27 | 28 | // different than Apple Swift, we use nil terminator as default instead of "\n", to mean cross-platform new-line 29 | @inline(__always) public func debugPrint(_ object: Object?, separator: String, terminator: String?) { 30 | if let object = object { 31 | write(String(reflecting:object)) 32 | } else { 33 | write("(null)") 34 | } 35 | if let terminator = terminator { 36 | write(terminator) 37 | } else { 38 | writeLn() 39 | } 40 | } 41 | 42 | // different than Apple Swift, we use nil terminator as default instead of "\n", to mean cross-platform new-line 43 | public func debugPrint(_ objects: Object?..., separator: String = " ", terminator: String? = nil) { 44 | var first = true 45 | for object in objects { 46 | if !first { 47 | write(separator) 48 | } else { 49 | first = false 50 | } 51 | if let object = object { 52 | write(String(reflecting:object)) 53 | } else { 54 | write("(null)") 55 | } 56 | } 57 | if let terminator = terminator { 58 | write(terminator) 59 | } else { 60 | writeLn() 61 | } 62 | } 63 | 64 | @discardableResult func dump(_ value: T, name: String? = nil, indent: Int = 2, maxDepth: Int = -1, maxItems: Int = -1) -> T 65 | { 66 | #if ISLAND && DARWIN 67 | switch modelOf(T) { 68 | case "Island": debugPrint((value as? IslandObject)?.ToString()) 69 | case "Cocoa": debugPrint((value as? CocoaObject)?.description) 70 | case "Swift": debugPrint((value as? SwiftObject)?.description) 71 | case "Delphi": throw Exception("This feature is not supported for Delphi Objects (yet)"); 72 | case "COM": throw Exception("This feature is not supported for COM Objects"); 73 | case "JNI": throw Exception("This feature is not supported for JNI Objects"); 74 | default: throw Exception("Unexpected object model \(modelOf(T))") 75 | } 76 | #else 77 | debugPrint(value as? Object) 78 | #endif 79 | return value 80 | } 81 | 82 | @noreturn public func fatalError(file: String = #file, line: UInt32 = #line) -> Never { 83 | __throw Exception("Fatal Error, file "+file+", line "+line) 84 | } 85 | 86 | @noreturn public func fatalError(_ message: @autoclosure () -> String, file: String = #file, line: UInt32 = #line) -> Never { 87 | if let message = message { 88 | __throw Exception(message()+", file "+file+", line "+line) 89 | } else { 90 | __throw Exception("Fatal Error, file "+file+", line "+line) 91 | } 92 | } 93 | 94 | @Conditional("DEBUG") public func precondition(_ condition: @autoclosure () -> Bool, _ message: @autoclosure () -> String, file: String = #file, line: UWord = #line) { 95 | if (!condition()) { 96 | fatalError(message, file: file, line: line) 97 | } 98 | } 99 | 100 | @Conditional("DEBUG") public func preconditionFailure(_ message: @autoclosure () -> String, file: String = #file, line: UWord = #line) -> Never { 101 | fatalError(message, file: file, line: line) 102 | } 103 | 104 | @Obsolete("Use print() instead") @inline(__always) public func println(_ objects: Any?...) { // no longer defined for Swift, but we're keeping it for backward compartibiolitry for now 105 | print(objects) 106 | } 107 | 108 | public func print(string: String) { 109 | write(string) 110 | } 111 | 112 | public func print(object: Object?, separator: String, terminator: String?) { 113 | if let object = object { 114 | write(object) 115 | } else { 116 | write("(null)") 117 | } 118 | if let terminator = terminator { 119 | write(terminator) 120 | } else { 121 | writeLn() 122 | } 123 | } 124 | 125 | @inline(__always) public func print(_ objects: Object?...) { 126 | print(objects, separator: " ", terminator: nil) 127 | } 128 | 129 | @inline(__always) public func print(_ objects: Object?..., separator: String) { 130 | print(objects, separator: separator, terminator: nil) 131 | } 132 | 133 | @inline(__always) public func print(_ objects: Object?..., terminator: String?) { 134 | print(objects, separator: " ", terminator: terminator) 135 | } 136 | 137 | // different than Apple Swift, we use nil terminator as default instead of "\n", to mean cross-platform new-line 138 | public func print(_ objects: Object?..., separator: String = " ", terminator: String? = nil) { 139 | var first = true 140 | for object in objects { 141 | if !first { 142 | write(separator) 143 | } else { 144 | first = false 145 | } 146 | write(__toString(object)) 147 | } 148 | if let terminator = terminator { 149 | write(terminator) 150 | } else { 151 | writeLn() 152 | } 153 | } 154 | 155 | // different than Apple Swift, we use nil terminator as default instead of "\n", to mean cross-platform new-line 156 | func print(_ objects: Object?..., separator: String = " ", terminator: String? = nil, to output: inout Target) { 157 | //var first = true 158 | //for object in objects { 159 | //if !first { 160 | //output.write(separator) 161 | //} else { 162 | //first = false 163 | //} 164 | //output.write(__toString(object)) 165 | //} 166 | //if let terminator = terminator { 167 | //output.write(terminator) 168 | //} else { 169 | //output.write(__newLine()) 170 | //} 171 | } 172 | 173 | public func readLine(# stripNewline: Bool = true) -> String { 174 | return readLn() + (!stripNewline ? __newLine() : "") 175 | } 176 | 177 | @inline(__always) public func swap(inout a: T, inout b: T) { 178 | let temp = a 179 | a = b 180 | b = temp 181 | } 182 | 183 | public func stride(from start: Int, to end: Int, by stride: Int) -> ISequence { 184 | var i = start 185 | if stride > 0 { 186 | while i < end { 187 | __yield i; 188 | i += stride 189 | } 190 | } else if stride < 0 { 191 | while i > end { 192 | __yield i; 193 | i += stride 194 | } 195 | } 196 | } 197 | 198 | public func stride(from start: Int, through end: Int, by stride: Int) -> ISequence { 199 | var i = start 200 | if stride > 0 { 201 | while i <= end { 202 | __yield i; 203 | i += stride 204 | } 205 | } else if stride < 0 { 206 | while i >= end { 207 | __yield i; 208 | i += stride 209 | } 210 | } 211 | } 212 | 213 | public func stride(from start: Double, to end: Double, by stride: Double) -> ISequence { 214 | var i = start 215 | if stride > 0 { 216 | while i < end { 217 | __yield i; 218 | i += stride 219 | } 220 | } else if stride < 0 { 221 | while i > end { 222 | __yield i; 223 | i += stride 224 | } 225 | } 226 | } 227 | 228 | #if !TOFFEE 229 | public func stride(from start: Double, through end: Double, by stride: Double) -> ISequence { 230 | var i = start 231 | if stride > 0 { 232 | while i <= end { 233 | __yield i; 234 | i += stride 235 | } 236 | } else if stride < 0 { 237 | while i >= end { 238 | __yield i; 239 | i += stride 240 | } 241 | } 242 | } 243 | #endif 244 | 245 | #if COOPER || TOFFEE 246 | @inline(always) public func type(of value: Any) -> Class { 247 | return typeOf(value) 248 | } 249 | #elseif ECHOES || ISLAND 250 | @inline(always) public func type(of value: Any) -> Type { 251 | return typeOf(value) 252 | } 253 | #endif 254 | 255 | 256 | #if TOFFEE 257 | 258 | public func autoreleasepool(_ act: () throws -> (T)) -> T throws { 259 | var res: T; 260 | autoreleasepool { 261 | res = try act(); 262 | } 263 | return res; 264 | } 265 | 266 | public func autoreleasepool(_ act: () -> (T)) -> T { 267 | var res: T; 268 | autoreleasepool { 269 | res = try act(); 270 | } 271 | return res; 272 | } 273 | 274 | #endif -------------------------------------------------------------------------------- /Source/Functions_ObjC.swift: -------------------------------------------------------------------------------- 1 |  2 | /*func isUniquelyReferencedNonObjC(inout object: T?) -> Bool { 3 | return false 4 | }*/ -------------------------------------------------------------------------------- /Source/INonLazySequence_Extensions.swift: -------------------------------------------------------------------------------- 1 | //public typealias SequenceType = INonLazySequence 2 | 3 | public protocol INonLazySequence { 4 | // Todo: redefine each platform's core ISequence methods. 5 | } 6 | 7 | public extension INonLazySequence { 8 | // Todo: reimplement all the ISequence extensions, but non-lazy. 9 | } -------------------------------------------------------------------------------- /Source/Index_Protocols.swift: -------------------------------------------------------------------------------- 1 |  2 | public protocol ForwardIndexType { 3 | associatedtype Distance /*: SignedIntegerType*/ = Int 4 | func advancedBy(_ n: Self.Distance) -> Self 5 | func advancedBy(_ n: Self.Distance, limit: Self) -> Self 6 | func distanceTo(_ end: Self) -> Self.Distance 7 | } 8 | 9 | public protocol BidirectionalIndexType : ForwardIndexType { 10 | //func advancedBy(_ n: Self.Distance) -> Self // duped from ForwardIndexType? 11 | //func advancedBy(_ n: Self.Distance, limit limit: Self) -> Self // duped from ForwardIndexType? 12 | func predecessor() -> Self 13 | func successor() -> Self 14 | } 15 | 16 | public protocol ReverseIndexType : BidirectionalIndexType { 17 | associatedtype Base : BidirectionalIndexType 18 | //associatedtype Distance : SignedIntegerType = Self.Base.Distance // duped from ForwardIndexType? 19 | init(_ base: Self.Base) 20 | var base: Self.Base { get } 21 | } 22 | 23 | public protocol Strideable : Comparable { 24 | associatedtype Stride : SignedNumberType 25 | //74968: Silver: compiler ignores undefined associated type (`Self.whatever`) 26 | 27 | func advancedBy(_ n: Self.Stride) -> Self 28 | func distanceTo(_ other: Self) -> Self.Stride 29 | func stride(# through: Self, by: Self) -> ISequence 30 | func stride(# to: Self, by: Self) -> ISequence 31 | } 32 | 33 | public protocol RandomAccessIndexType : BidirectionalIndexType, Strideable { 34 | //func advancedBy(_ n: Self.Distance) -> Self // duped from ForwardIndexType? 35 | //func advancedBy(_ n: Self.Distance, limit limit: Self) -> Self // duped from ForwardIndexType? 36 | //func distanceTo(_ other: Self) -> Self.Distance // duped from ForwardIndexType? 37 | } 38 | 39 | // workaround for error E36: Interface type expected, found "IntegerLiteralConvertible!" 40 | public protocol IntegerType : RandomAccessIndexType { 41 | // no members 42 | } -------------------------------------------------------------------------------- /Source/Integer_Protocols.swift: -------------------------------------------------------------------------------- 1 |  2 | /* Numbers */ 3 | 4 | //public typealias Equatable = IEquatable 5 | public protocol Equatable { // NE19 The public type "IEquatable" has a duplicate with the same short name, which is not allowed on Cocoa 6 | func ==(lhs: Self, rhs: Self) -> Bool 7 | } 8 | 9 | //public typealias Comparable = IComparable 10 | public protocol Comparable : Equatable { 11 | func <(lhs: Self, rhs: Self) -> Bool 12 | func <=(lhs: Self, rhs: Self) -> Bool 13 | func >=(lhs: Self, rhs: Self) -> Bool 14 | func >(lhs: Self, rhs: Self) -> Bool 15 | } 16 | 17 | public typealias IIncrementable = Incrementable 18 | public protocol Incrementable : Equatable { 19 | func successor() -> Self 20 | } 21 | 22 | // CAUTION: Magic type name. 23 | // The compiler will allow any value implementing Swift.IBooleanType type to be used as boolean 24 | public typealias IBooleanType = BooleanType 25 | public protocol BooleanType { 26 | var boolValue: Bool { get } 27 | } 28 | 29 | public protocol IntegerArithmeticType : Comparable { 30 | //class func addWithOverflow(lhs: Self, _ rhs: Self) -> (Self, overflow: Bool) //71481: Silver: can't use Self in tuple on static funcs i(in public protocols?) 31 | //class func subtractWithOverflow(lhs: Self, _ rhs: Self) -> (Self, overflow: Bool) 32 | //class func multiplyWithOverflow(lhs: Self, _ rhs: Self) -> (Self, overflow: Bool) 33 | //class func divideWithOverflow(lhs: Self, _ rhs: Self) -> (Self, overflow: Bool) 34 | //class func remainderWithOverflow(lhs: Self, _ rhs: Self) -> (Self, overflow: Bool) 35 | 36 | func +(lhs: Self, rhs: Self) -> Self 37 | func -(lhs: Self, rhs: Self) -> Self 38 | func *(lhs: Self, rhs: Self) -> Self 39 | func /(lhs: Self, rhs: Self) -> Self 40 | func %(lhs: Self, rhs: Self) -> Self 41 | func toIntMax() -> IntMax 42 | } 43 | 44 | public protocol BitwiseOperationsType { 45 | //func &(_: Self, _: Self) -> Self //69825: Silver: two probs with operators in public protocols 46 | func |(_: Self, _: Self) -> Self 47 | func ^(_: Self, _: Self) -> Self 48 | prefix func ~(_: Self) -> Self 49 | 50 | /// The identity value for "|" and "^", and the fixed point for "&". 51 | /// 52 | /// :: 53 | /// 54 | /// x | allZeros == x 55 | /// x ^ allZeros == x 56 | /// x & allZeros == allZeros 57 | /// x & ~allZeros == x 58 | /// 59 | //static/*class*/ var allZeros: Self { get } 60 | } 61 | 62 | public typealias SignedNumberType = ISignedNumberType 63 | public protocol ISignedNumberType : Comparable, IntegerLiteralConvertible { 64 | prefix func -(_ x: Self) -> Self 65 | func -(_ lhs: Self, _ rhs: Self) -> Self 66 | } 67 | 68 | public protocol AbsoluteValuable : SignedNumberType { 69 | static func abs(_ x: Self) -> Self 70 | } 71 | 72 | public typealias SignedIntegerType = ISignedIntegerType 73 | public protocol ISignedIntegerType { 74 | init(_ value: IntMax) 75 | func toIntMax() -> IntMax 76 | } 77 | 78 | public typealias UnsignedIntegerType = IUnsignedIntegerType 79 | public protocol IUnsignedIntegerType { 80 | init(_ value: UIntMax) 81 | func toUIntMax() -> UIntMax 82 | } -------------------------------------------------------------------------------- /Source/LiteralConvertibles.swift: -------------------------------------------------------------------------------- 1 | public typealias ExpressibleByArrayLiteral = IExpressibleByArrayLiteral 2 | public typealias ExpressibleByBooleanLiteral = IExpressibleByBooleanLiteral 3 | public typealias ExpressibleByDictionaryLiteral = IExpressibleByDictionaryLiteral 4 | //public typealias ExpressibleByExtendedGraphemeClusterLiteral = IExpressibleByExtendedGraphemeClusterLiteral 5 | public typealias ExpressibleByFloatLiteral = IExpressibleByFloatLiteral 6 | public typealias ExpressibleByIntegerLiteral = IExpressibleByIntegerLiteral 7 | public typealias ExpressibleByNilLiteral = IExpressibleByNilLiteral 8 | public typealias ExpressibleByStringLiteral = IExpressibleByStringLiteral 9 | public typealias ExpressibleByStringInterpolation = IExpressibleByStringInterpolation 10 | public typealias ExpressibleByUnicodeScalarLiteral = IExpressibleByUnicodeScalarLiteral 11 | 12 | public typealias NilLiteralConvertible = ExpressibleByNilLiteral 13 | public typealias BooleanLiteralConvertible = ExpressibleByBooleanLiteral 14 | public typealias FloatLiteralConvertible = ExpressibleByFloatLiteral 15 | public typealias IntegerLiteralConvertible = ExpressibleByIntegerLiteral 16 | public typealias UnicodeScalarLiteralConvertible = ExpressibleByUnicodeScalarLiteral 17 | //public typealias ExtendedGraphemeClusterLiteralConvertible = ExpressibleByExtendedGraphemeClusterLiteral 18 | public typealias StringLiteralConvertible = ExpressibleByStringLiteral 19 | public typealias StringInterpolationConvertible = ExpressibleByStringInterpolation 20 | public typealias ArrayLiteralConvertible = ExpressibleByArrayLiteral 21 | public typealias DictionaryLiteralConvertible = ExpressibleByDictionaryLiteral 22 | 23 | public protocol IExpressibleByArrayLiteral { 24 | associatedtype Element 25 | 26 | init(arrayLiteral elements: Element...) 27 | } 28 | 29 | public protocol IExpressibleByBooleanLiteral { 30 | associatedtype BooleanLiteralType 31 | 32 | init(booleanLiteral value: BooleanLiteralType) 33 | } 34 | 35 | public protocol IExpressibleByDictionaryLiteral { 36 | associatedtype Key 37 | associatedtype Value 38 | 39 | init(dictionaryLiteral elements: (Key, Value)...) 40 | } 41 | 42 | //73998: Silver: compiler crash in base library 43 | public protocol IExpressibleByExtendedGraphemeClusterLiteral /*: ExpressibleByUnicodeScalarLiteral*/ { 44 | associatedtype ExtendedGraphemeClusterLiteralType 45 | 46 | /// Create an instance initialized to `value`. 47 | init(extendedGraphemeClusterLiteral value: ExtendedGraphemeClusterLiteralType) 48 | } 49 | 50 | public protocol IExpressibleByFloatLiteral { 51 | associatedtype FloatLiteralType 52 | 53 | init(floatLiteral value: FloatLiteralType) 54 | } 55 | 56 | public protocol IExpressibleByIntegerLiteral { 57 | associatedtype IntegerLiteralType 58 | 59 | init(integerLiteral value: IntegerLiteralType) 60 | } 61 | 62 | public protocol IExpressibleByNilLiteral { 63 | 64 | //init(nilLiteral: ()) 65 | } 66 | 67 | public protocol IExpressibleByStringLiteral /*: ExpressibleByExtendedGraphemeClusterLiteral*/ { 68 | associatedtype StringLiteralType 69 | 70 | init(stringLiteral value: StringLiteralType) 71 | } 72 | 73 | public protocol IExpressibleByStringInterpolation /*: ExpressibleByExtendedGraphemeClusterLiteral*/ { 74 | associatedtype StringInterpolationType 75 | 76 | init(stringInterpolation value: StringInterpolationType) 77 | } 78 | 79 | public protocol IExpressibleByUnicodeScalarLiteral { 80 | associatedtype UnicodeScalarLiteralType 81 | 82 | init(unicodeScalarLiteral value: UnicodeScalarLiteralType) 83 | } 84 | 85 | #if COCOA 86 | public extension NSURL/*: ExpressibleByStringLiteral*/ { 87 | 88 | //typealias ExtendedGraphemeClusterLiteralType = StringLiteralType 89 | 90 | public class func convertFromExtendedGraphemeClusterLiteral(value: String) -> Self { 91 | return self(string: value) 92 | } 93 | 94 | init(stringLiteral value: String) { 95 | return NSURL(string: value) 96 | } 97 | } 98 | #endif -------------------------------------------------------------------------------- /Source/MemoryLayout.swift: -------------------------------------------------------------------------------- 1 | //public struct MemoryLayout { 2 | 3 | //var size: Byte { sizeOf } 4 | //var alignment: Byte { sizeOf } 5 | //var stride: Byte { sizeOf } 6 | 7 | //} -------------------------------------------------------------------------------- /Source/Mirror.swift: -------------------------------------------------------------------------------- 1 |  2 | public typealias CustomReflectable = ICustomReflectable 3 | public protocol ICustomReflectable { 4 | func customMirror() -> Mirror 5 | } 6 | 7 | public typealias CustomLeafReflectable = ICustomLeafReflectable 8 | public protocol ICustomLeafReflectable : ICustomReflectable { 9 | } 10 | 11 | public typealias MirrorPathType = IMirrorPathType 12 | public protocol IMirrorPathType { 13 | } 14 | 15 | public class Mirror : ICustomStringConvertible, ICustomReflectable, IStreamable { 16 | 17 | // 18 | // Type Aliases 19 | // 20 | 21 | typealias Child = (label: String?, value: Any) 22 | typealias Children = ISequence // AnyForwardCollection 23 | 24 | // 25 | // Initializers 26 | // 27 | 28 | //74065: Silver: "cannot assign nil to [nullable enum type]" 29 | /*init(_ subject: Any, children: ISequence, displayStyle: Mirror.DisplayStyle? = nil, ancestorRepresentation: Mirror.AncestorRepresentation = Mirror.AncestorRepresentation.Generated) { 30 | }*/ 31 | 32 | //74065: Silver: "cannot assign nil to [nullable enum type]" 33 | /*init(_ subject: Any, children: Children, displayStyle: Mirror.DisplayStyle? = /*nil*/Mirror.DisplayStyle.Class, ancestorRepresentation: Mirror.AncestorRepresentation = Mirror.AncestorRepresentation.Generated) { 34 | }*/ 35 | 36 | //init(_:unlabeledChildren:displayStyle:ancestorRepresentation:) 37 | init(reflecting subject: Any) { 38 | } 39 | 40 | // 41 | // Properties 42 | // 43 | 44 | var children: Children { 45 | fatalError("Not implemented yet") 46 | } 47 | #if COCOA 48 | override var description: String! { 49 | #else 50 | var description: String! { 51 | #endif 52 | return "ToDo" 53 | } 54 | let displayStyle: Mirror.DisplayStyle? = nil 55 | //let subjectType: Any.Type 56 | 57 | // 58 | // Methods 59 | // 60 | 61 | func customMirror() -> Mirror { 62 | fatalError("Not implemented yet") 63 | } 64 | func descendant(_ first: IMirrorPathType, _ rest: IMirrorPathType...) -> Any? { 65 | fatalError("Not implemented yet") 66 | } 67 | func superclassMirror() -> Mirror? { 68 | fatalError("Not implemented yet") 69 | } 70 | 71 | // 72 | // Interfaces 73 | // 74 | 75 | func writeTo(inout _ target: Target) { 76 | //target.writeTo(description) // 74052: Silver: generic contraints don't seem to work 77 | } 78 | 79 | // 80 | // Nested Types 81 | // 82 | 83 | public enum DisplayStyle { 84 | case Struct, Class, Enum, Tuple, Optional, Collection, Dictionary, Set 85 | } 86 | 87 | public enum AncestorRepresentation { 88 | case Generated 89 | //case Customized(()->Mirror) // 74066: Silver: can't use an enum as default value, if it also has "more fancy" items 90 | case Suppressed 91 | } 92 | 93 | 94 | } -------------------------------------------------------------------------------- /Source/NSArray_Extensions.swift: -------------------------------------------------------------------------------- 1 | #if TOFFEE 2 | public extension NSArray { 3 | 4 | init(nativeArray: ObjectType[]) { 5 | let result = NSMutableArray(capacity: length(nativeArray)) 6 | for e in nativeArray { 7 | result.addObject(e) 8 | } 9 | return result 10 | } 11 | 12 | init(array: [ObjectType]) { 13 | return array as! ISequence // 74041: Silver: warning for "as" cast that should be known safe 14 | } 15 | 16 | public func ToSwiftArray() -> [ObjectType] { 17 | //workaround for E25642: Island/Darwin: can't use generic params with Cocoa collection even if consrained to NSObject 18 | //if let array = self as? [ObjectType] { 19 | //return array.platformList 20 | //} 21 | var result = [ObjectType]() 22 | for i in self { 23 | result.append(i) 24 | } 25 | return result 26 | } 27 | 28 | #if !COOPER 29 | public func ToSwiftArray() -> [U] { 30 | var result = [U]() 31 | for i in self { 32 | result.append(i as! U) 33 | } 34 | return result 35 | } 36 | #endif 37 | 38 | public func dropFirst() -> ISequence { 39 | return self.Skip(1) 40 | } 41 | 42 | public func dropFirst(_ n: Int) -> ISequence { 43 | return self.Skip(n) 44 | } 45 | 46 | public func dropLast() -> ISequence { 47 | fatalError("dropLast() is not implemented yet.") 48 | } 49 | 50 | public func dropLast(_ n: Int) -> ISequence { 51 | fatalError("dropLast() is not implemented yet.") 52 | } 53 | 54 | public func enumerated() -> ISequence<(Int, ObjectType)> { 55 | var index = 0 56 | for element in self { 57 | __yield (index++, element) 58 | } 59 | } 60 | 61 | public func indexOf(@noescape _ predicate: (ObjectType) -> Bool) -> Int? { 62 | for (i, element) in self.enumerated() { 63 | if (predicate(element) == true){ 64 | return i 65 | } 66 | } 67 | return nil 68 | } 69 | 70 | public func filter(_ includeElement: (ObjectType) throws -> Bool) rethrows -> ISequence { 71 | return self.Where() { return try! includeElement($0) } 72 | } 73 | 74 | public func count(`where` countElement: (ObjectType) throws -> Bool) rethrows -> Int { 75 | var result = 0; 76 | for i in self { 77 | if try countElement(i) { 78 | result++ 79 | } 80 | } 81 | return result 82 | } 83 | 84 | public var first: ObjectType? { 85 | return self.FirstOrDefault() 86 | } 87 | 88 | func flatMap(@noescape _ transform: (ObjectType) throws -> ObjectType?) rethrows -> ISequence { 89 | for e in self { 90 | if let e = try! transform(e) { 91 | __yield e 92 | } 93 | } 94 | } 95 | 96 | public func flatten() -> ISequence { // no-op in Silver? i dont get what this does. 97 | return self 98 | } 99 | 100 | public func forEach(@noescape body: (ObjectType) throws -> ()) rethrows { 101 | for e in self { 102 | try! body(e) 103 | } 104 | } 105 | 106 | @Obsolete("generate() is not supported in Silver.", true) public func generate() -> ISequence { // no-op in Silver? i dont get what this does. 107 | fatalError("generate() is not supported in Silver.") 108 | } 109 | 110 | public var isEmpty: Bool { 111 | return !self.Any() 112 | } 113 | 114 | public func joined(separator: String) -> String { 115 | var first = true 116 | var result = "" 117 | for e in self { 118 | if !first { 119 | result += separator 120 | } else { 121 | first = false 122 | } 123 | result += e.description 124 | } 125 | return result 126 | } 127 | 128 | public func joined(separator: ISequence) -> ISequence { 129 | var first = true 130 | for e in self { 131 | if !first { 132 | for i in separator { 133 | __yield i 134 | } 135 | } else { 136 | first = false 137 | } 138 | __yield e 139 | } 140 | } 141 | 142 | public func joined(separator: ObjectType[]) -> ISequence { 143 | var first = true 144 | for e in self { 145 | if !first { 146 | for i in separator { 147 | __yield i 148 | } 149 | } else { 150 | first = false 151 | } 152 | __yield e 153 | } 154 | } 155 | 156 | public var lazy: ISequence { // sequences are always lazy in Silver 157 | return self 158 | } 159 | 160 | public func map(_ transform: (ObjectType) -> U) -> ISequence { 161 | return self.Select() { return transform($0) } 162 | } 163 | 164 | //74101: Silver: still two issues with try! 165 | public func maxElement(_ isOrderedBefore: (ObjectType, ObjectType) /*throws*/ -> Bool) -> ObjectType? { 166 | var m: ObjectType? = nil 167 | for e in self { 168 | if m == nil || /*try!*/ !isOrderedBefore(m!, e) { // ToDo: check if this is the right order 169 | m = e 170 | } 171 | } 172 | return m 173 | } 174 | 175 | public func minElement(_ isOrderedBefore: (ObjectType, ObjectType) /*throws*/ -> Bool) -> ObjectType? { 176 | var m: ObjectType? = nil 177 | for e in self { 178 | if m == nil || /*try!*/ isOrderedBefore(m!, e) { // ToDo: check if this is the right order 179 | m = e 180 | } 181 | } 182 | return m 183 | } 184 | 185 | public func `prefix`(_ maxLength: Int) -> ISequence { 186 | return self.Take(maxLength) 187 | } 188 | 189 | public func reduce(_ initial: U, _ combine: (U, ObjectType) -> U) -> U { 190 | var value = initial 191 | for i in self { 192 | value = combine(value, i) 193 | } 194 | return value 195 | } 196 | 197 | public func reverse() -> ISequence { 198 | return self.Reverse() 199 | } 200 | 201 | public func sorted(by isOrderedBefore: (ObjectType, ObjectType) -> Bool) -> ISequence { 202 | //todo: make more lazy? 203 | #if JAVA 204 | let result = self.ToList() 205 | java.util.Collections.sort(result, class java.util.Comparator { func compare(a: ObjectType, b: ObjectType) -> Int32 { // ToDo: check if this is the right order 206 | if isOrderedBefore(a,b) { 207 | return 1 208 | } else { 209 | return -1 210 | } 211 | }}) 212 | return result 213 | #elseif CLR || ISLAND 214 | let result = self.ToList() 215 | result.Sort() { (a: ObjectType, b: ObjectType) -> Integer in // ToDo: check if this is the right order 216 | if isOrderedBefore(a,b) { 217 | return -1 218 | } else { 219 | return 1 220 | } 221 | } 222 | return result 223 | #elseif COCOA 224 | return self.ToNSArray().sortedArrayWithOptions(0, usingComparator: { (a: id!, b: id!) -> NSComparisonResult in // ToDo: check if this is the right order 225 | if isOrderedBefore(a == NSNull.null ? nil : a, b == NSNull.null ? nil : b) { 226 | return .NSOrderedDescending 227 | } else { 228 | return .NSOrderedAscending 229 | } 230 | })! 231 | #endif 232 | } 233 | 234 | /*public func split(_ isSeparator: (ObjectType) -> Bool, maxSplit: Int = 0, allowEmptySlices: Bool = false) -> ISequence> { 235 | 236 | let result = [String]() 237 | var currentString = "" 238 | 239 | func appendCurrent() -> Bool { 240 | if maxSplit > 0 && result.count >= maxSplit { 241 | return false 242 | } 243 | if allowEmptySlices || currentString.length() > 0 { 244 | result.append(currentString) 245 | } 246 | return true 247 | } 248 | 249 | for var i = 0; i < elements.length(); i++ { 250 | let ch = elements[i] 251 | if isSeparator(ch) { 252 | if !appendCurrent() { 253 | break 254 | } 255 | currentString = "" 256 | } else { 257 | currentString += ch 258 | } 259 | } 260 | 261 | if currentString.length() > 0 { 262 | appendCurrent() 263 | } 264 | 265 | return result 266 | }*/ 267 | 268 | public func startsWith(`prefix` p: ISequence) -> Bool { 269 | #if JAVA 270 | let sEnum = self.iterator() 271 | let pEnum = p.iterator() 272 | while true { 273 | if pEnum.hasNext() { 274 | let pVal = pEnum.next() 275 | if sEnum.hasNext() { 276 | let sVal = sEnum.next() 277 | if (pVal == nil && sVal == nil) { 278 | // both nil is oke 279 | } else if pVal != nil && sVal != nil && pVal.equals(sVal) { 280 | // Neither nil and equals true is oke 281 | } else { 282 | return false // Different values 283 | } 284 | } else { 285 | return false // reached end of s 286 | } 287 | 288 | } else { 289 | return true // reached end of prefix 290 | } 291 | } 292 | #elseif CLR || ISLAND 293 | let pEnum = p.GetEnumerator() 294 | for c in self { 295 | if pEnum.MoveNext() { 296 | #if CLR 297 | if !EqualityComparer.Default.Equals(c, pEnum.Current) { 298 | return false // cound mismatch 299 | } 300 | #elseif ISLAND 301 | if c == nil && pEnum.Current == nil { 302 | } else if c != nil && pEnum.Current != nil && c.Equals(pEnum.Current) { 303 | } else { 304 | return false 305 | } 306 | #endif 307 | } else { 308 | return true // reached end of prefix 309 | } 310 | } 311 | return true // reached end of s 312 | #elseif COCOA 313 | let LOOP_SIZE = 16 314 | let sState: NSFastEnumerationState = `default`(NSFastEnumerationState) 315 | let pState: NSFastEnumerationState = `default`(NSFastEnumerationState) 316 | var sObjects = ObjectType[](count: LOOP_SIZE) 317 | var pObjects = ObjectType[](count: LOOP_SIZE) 318 | 319 | while true { 320 | let sCount = self.countByEnumeratingWithState(&sState, objects: sObjects, count: LOOP_SIZE) 321 | let pCount = p.countByEnumeratingWithState(&pState, objects: pObjects, count: LOOP_SIZE) 322 | if pCount > sCount { 323 | return false // s is shorter than prefix 324 | } 325 | if pCount == 0 { 326 | return true // reached end of prefix 327 | } 328 | for i in 0 ..< sCount { 329 | if i > pCount { 330 | return true // reached end of prefix 331 | } 332 | if !(sState.itemsPtr[i] as! Any).isEqual(pState.itemsPtr[i]) { 333 | return false // found mismatch 334 | } 335 | } 336 | } 337 | #endif 338 | } 339 | 340 | public func suffix(_ maxLength: Int) -> ISequence { 341 | fatalError("suffix() is not implemented yet.") 342 | } 343 | 344 | public func underestimateCount() -> Int { // we just return the accurate count here 345 | return self.Count() 346 | } 347 | 348 | // 349 | // Silver-specific extensions not defined in standard Swift.Array: 350 | // 351 | 352 | /*public func nativeArray() -> ObjectType[] { 353 | #if JAVA 354 | //return self.toArray()//ObjectType[]()) 355 | #elseif CLR 356 | return self.ToArray() 357 | #elseif COCOA 358 | //return self.array() 359 | #endif 360 | }*/ 361 | 362 | public func toSwiftArray() -> [ObjectType] { 363 | #if JAVA 364 | let result = ArrayList() 365 | for e in self { 366 | result.add(e); 367 | } 368 | return [ObjectType](result) 369 | #elseif CLR || ISLAND 370 | return [ObjectType](self.ToList()) 371 | #elseif COCOA 372 | return [ObjectType](self.ToNSArray()) 373 | #endif 374 | } 375 | 376 | public func contains(_ item: ObjectType) -> Bool { 377 | return self.Contains(item) 378 | } 379 | 380 | #if COCOA 381 | override var debugDescription: String! { 382 | var result = "Sequence(" 383 | var first = true 384 | for e in self { 385 | if !first { 386 | result += ", " 387 | } else { 388 | first = false 389 | } 390 | result += String(reflecting: e) 391 | } 392 | result += ")" 393 | return result 394 | } 395 | #else 396 | public var debugDescription: String { 397 | var result = "Sequence(" 398 | var first = true 399 | for e in self { 400 | if !first { 401 | result += ", " 402 | } else { 403 | first = false 404 | } 405 | result += String(reflecting: e) 406 | } 407 | result += ")" 408 | return result 409 | } 410 | #endif 411 | } 412 | 413 | #endif -------------------------------------------------------------------------------- /Source/Nougat.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | 4 | -------------------------------------------------------------------------------- /Source/Number_Constructors.swift: -------------------------------------------------------------------------------- 1 | // ctors 2 | 3 | #if COCOA 4 | fileprivate static func parseNumber(_ value: String) -> NSNumber? { 5 | var value = value 6 | let formatter = NSNumberFormatter() 7 | formatter.numberStyle = .decimalStyle 8 | formatter.locale = nil 9 | if value.hasPrefix("+") && value.range(of: "-").location == NSNotFound { // NSNumberFormatter doesn't like +, strip it; 10 | value = value.substring(fromIndex: 1) 11 | } 12 | return formatter.numberFromString(value) 13 | } 14 | #endif 15 | 16 | public extension Int8 { 17 | 18 | init(_ value: String) { 19 | if #defined(JAVA) { 20 | return java.lang.Byte.parseByte(value); 21 | } else if #defined(CLR) || #defined(ISLAND) { 22 | return Int8.Parse(value); 23 | } else if #defined(COCOA) { 24 | if let result = parseNumber(value) { 25 | return result.shortValue 26 | } else { 27 | throw Exception("Error parsing Integer") 28 | } 29 | } 30 | } 31 | } 32 | 33 | public extension Int16 { 34 | 35 | init(_ value: String) { 36 | if #defined(JAVA) { 37 | return java.lang.Integer.parseInt(value); 38 | } else if #defined(CLR) || #defined(ISLAND) { 39 | return Int16.Parse(value); 40 | } else if #defined(COCOA) { 41 | if let result = parseNumber(value) { 42 | return result.shortValue 43 | } else { 44 | throw Exception("Error parsing Integer") 45 | } 46 | } 47 | } 48 | } 49 | 50 | public extension Int32 { 51 | 52 | init(_ value: String) { 53 | if #defined(JAVA) { 54 | return java.lang.Integer.parseInt(value); 55 | } else if #defined(CLR) || #defined(ISLAND) { 56 | return Int32.Parse(value); 57 | } else if #defined(COCOA) { 58 | if let result = parseNumber(value) { 59 | return result.intValue 60 | } else { 61 | throw Exception("Error parsing Integer") 62 | } 63 | } 64 | } 65 | } 66 | 67 | public extension Int64 { 68 | 69 | init(_ value: String) { 70 | if #defined(JAVA) { 71 | return java.lang.Long.parseLong(value) 72 | } else if #defined(CLR) || #defined(ISLAND) { 73 | return Int64.Parse(value) 74 | } else if #defined(COCOA) { 75 | if let result = parseNumber(value) { 76 | return result.longValue 77 | } else { 78 | throw Exception("Error parsing Integer") 79 | } 80 | } 81 | } 82 | } 83 | 84 | public extension Float { 85 | 86 | init(_ value: String) { 87 | if #defined(JAVA) { 88 | return java.lang.Float.parseFloat(value); 89 | } else if #defined(CLR) || #defined(ISLAND) { 90 | return Float.Parse(value); 91 | } else if #defined(COCOA) { 92 | if let result = parseNumber(value) { 93 | return result.floatValue 94 | } else { 95 | throw Exception("Error parsing Integer") 96 | } 97 | } 98 | } 99 | } 100 | 101 | public extension Double { 102 | 103 | init(_ value: String) { 104 | if #defined(JAVA) { 105 | return java.lang.Double.parseDouble(value); 106 | } else if #defined(CLR) || #defined(ISLAND) { 107 | return Double.Parse(value); 108 | } else if #defined(COCOA) { 109 | if let result = parseNumber(value) { 110 | return result.doubleValue 111 | } else { 112 | throw Exception("Error parsing Integer") 113 | } 114 | } 115 | } 116 | } -------------------------------------------------------------------------------- /Source/Object_Extensions.swift: -------------------------------------------------------------------------------- 1 |  2 | #if !COCOA 3 | public extension Object : CustomStringConvertible, CustomDebugStringConvertible { 4 | 5 | @inline(__always) public var description: NativeString { 6 | #if JAVA 7 | return self.toString() 8 | #elseif CLR || ISLAND 9 | return self.ToString() 10 | #endif 11 | } 12 | 13 | @inline(__always) public var debugDescription: NativeString! { 14 | #if JAVA 15 | return self.toString() 16 | #elseif CLR || ISLAND 17 | return self.ToString() 18 | #endif 19 | } 20 | } 21 | #endif 22 | 23 | public extension Object { 24 | 25 | public var hashValue: Int { 26 | #if JAVA 27 | return self.hashCode() 28 | #elseif CLR || ISLAND 29 | return self.GetHashCode() 30 | #elseif COCOA 31 | return self.hashValue() 32 | #endif 33 | } 34 | } -------------------------------------------------------------------------------- /Source/Operators.swift: -------------------------------------------------------------------------------- 1 | public postfix func !! (b: T?) -> T { 2 | if let x = b { 3 | return x 4 | } 5 | #if JAVA 6 | __throw NullPointerException("Cannot force-unwrap reference") 7 | #elseif CLR || ISLAND 8 | __throw NullReferenceException("Cannot force-unwrap reference") 9 | #elseif COCOA 10 | __throw NSException(name: "Cannot force-unwrap reference", reason: "Cannot force-unwrap reference", userInfo: nil) 11 | #endif 12 | } 13 | 14 | // 15 | // 16 | // CAUTION: Magic function name. 17 | // The compiler will use UnwrapOrDie to provide the `!!` Unwrap-or-die operator (SE-0217) 18 | // 19 | // 20 | 21 | public func UnwrapOrDie(_ val: T?, _ error: NativeString) -> T { 22 | if let val = val { 23 | return val 24 | } 25 | throw Exception(error) 26 | } -------------------------------------------------------------------------------- /Source/Pointers.swift: -------------------------------------------------------------------------------- 1 | #if !JAVA 2 | public extension OpaquePointer { 3 | 4 | //init(_ pointer: UnsafePointer) { 5 | 6 | //} 7 | //init(_ pointer: UnsafeMutablePointer) { 8 | 9 | //} 10 | //init?(_ pointer: UnsafePointer?) { 11 | 12 | //} 13 | //init?(_ pointer: UnsafeMutablePointer?) { 14 | 15 | //} 16 | init(_ pointer: UnsafeRawPointer?) { 17 | return pointer 18 | } 19 | init?(bitPattern: Int) { 20 | return bitPattern as! OpaquePointer 21 | } 22 | init?(bitPattern: UInt) { 23 | return bitPattern as! OpaquePointer 24 | } 25 | 26 | //@ToString // E201 Attributes of type "ToStringAspect!" are not allowed on this member 27 | var description: String { 28 | return "0x"+(self as! UInt).toHexString() 29 | } 30 | 31 | var debugDescription: String { 32 | return "0x"+(self as! UInt).toHexString() 33 | } 34 | 35 | //func hash(into: inout Hasher) { 36 | 37 | //} 38 | //static func != (_ rhs: OpaquePointer, _lhs: OpaquePointer) -> Bool { 39 | // handled by compiler 40 | //} 41 | //static func == (OpaquePointer, OpaquePointer) -> Bool { 42 | // handled by compiler 43 | //} 44 | } 45 | 46 | #endif -------------------------------------------------------------------------------- /Source/Protocols.swift: -------------------------------------------------------------------------------- 1 |  2 | #if COCOA 3 | /*@unsafe_no_objc_tagged_pointer*/ public protocol _CocoaArrayType { 4 | func objectAtIndex(index: Int) -> AnyObject 5 | //func getObjects(_: UnsafeMutablePointer, range: _SwiftNSRange) 6 | //func countByEnumeratingWithState(state: UnsafeMutablePointer<_SwiftNSFastEnumerationState>, objects buffer: UnsafeMutablePointer, count len: Int) -> Int 7 | //func copyWithZone(_: OpaquePointer) -> _CocoaArrayType 8 | var count: Int { get } 9 | } 10 | #endif 11 | 12 | public typealias CustomStringConvertible = ICustomStringConvertible 13 | public protocol ICustomStringConvertible { 14 | var description: NativeString! { get } // unwrapped nullable for better Cocoa compatibility 15 | } 16 | 17 | public typealias CustomDebugStringConvertible = ICustomDebugStringConvertible 18 | public protocol ICustomDebugStringConvertible { 19 | var debugDescription: NativeString! { get } // unwrapped nullable for better Cocoa compatibility 20 | } 21 | 22 | public typealias RawRepresentable = IRawRepresentable 23 | public protocol IRawRepresentable { 24 | associatedtype RawValue 25 | init/*?*/(rawValue rawValue: Self.RawValue) 26 | var rawValue: Self.RawValue { get } 27 | } 28 | 29 | public typealias ErrorType = IErrorType 30 | public protocol IErrorType { 31 | } 32 | 33 | public typealias Hashable = IHashable 34 | public protocol IHashable /*: Equatable*/ { 35 | var hashValue: Int { get } 36 | } 37 | 38 | typealias Identifiable = IIdentifiable 39 | protocol IIdentifiable { 40 | associatedtype ID: IHashable 41 | var id: ID { get } 42 | } 43 | 44 | public typealias OutputStreamType = IOutputStreamType 45 | public protocol IOutputStreamType { 46 | //mutating func write(_ string: String) 47 | } 48 | 49 | public typealias Streamable = IStreamable 50 | public protocol IStreamable { 51 | //func writeTo(inout _ target: OutputStreamType) 52 | func writeTo(_ target: OutputStreamType) // deliberately different that Apple's SBL due to limitations on Island 53 | } 54 | 55 | public typealias TextOutputStream = ITextOutputStream 56 | public protocol ITextOutputStream { 57 | mutating func write(_ string: String) 58 | } 59 | 60 | public typealias TextOutputStreamable = ITextOutputStreamable 61 | public protocol ITextOutputStreamable { 62 | //func write(to target: inout Target) where Target : TextOutputStream 63 | func write(to target: inout TextOutputStream) 64 | } 65 | 66 | public typealias StringProtocol = IStringProtocol 67 | public protocol IStringProtocol : ITextOutputStream { 68 | } 69 | 70 | // 71 | // Collections, Sequences and the like 72 | // 73 | 74 | /*public protocol GeneratorType { 75 | typealias Element 76 | mutating func next() -> Element? 77 | }*/ 78 | 79 | public typealias Actor = IActor 80 | protocol IActor : AnyObject, Sendable { 81 | } 82 | 83 | public typealias Sendable = ISendable 84 | protocol ISendable { 85 | } -------------------------------------------------------------------------------- /Source/Range.swift: -------------------------------------------------------------------------------- 1 |  2 | //74077: Allow GetSequence() to actually be used to implement ISequence 3 | 4 | public infix operator >.. {} 5 | 6 | public class Range/**/: CustomStringConvertible, CustomDebugStringConvertible { 7 | 8 | //typealias Index = Int64//Element 9 | typealias Bound = Int64 10 | 11 | // 12 | // Initializers 13 | // 14 | 15 | public init(_ x: Range/**/) { 16 | self.lowerBound = x.lowerBound 17 | self.upperBound = x.upperBound 18 | self.lowerBoundClosed = x.lowerBoundClosed 19 | self.upperBoundClosed = x.upperBoundClosed 20 | self.reversed = false 21 | } 22 | 23 | internal init(_ lowerBound: Bound?, _ upperBound: Bound?, upperBoundClosed: Bool = false, lowerBoundClosed: Bool = false) { 24 | self.lowerBound = lowerBound 25 | self.upperBound = upperBound 26 | self.lowerBoundClosed = lowerBoundClosed 27 | self.upperBoundClosed = upperBoundClosed 28 | self.reversed = false 29 | } 30 | 31 | internal init(_ lowerBound: Bound?, _ upperBound: Bound?, upperBoundClosed: Bool = false, lowerBoundClosed: Bool = false, reversed: Bool) { 32 | self.lowerBound = lowerBound 33 | self.upperBound = upperBound 34 | self.lowerBoundClosed = lowerBoundClosed 35 | self.upperBoundClosed = upperBoundClosed 36 | self.reversed = reversed 37 | } 38 | 39 | // 40 | // Properties 41 | // 42 | 43 | public var lowerBound: Bound? 44 | public var upperBound: Bound? 45 | public var upperBoundClosed: Bool 46 | public var lowerBoundClosed: Bool 47 | public var reversed: Bool 48 | 49 | var isEmpty: Bool { 50 | if let lowerBound = lowerBound, let upperBound = upperBound { 51 | if upperBoundClosed { 52 | return upperBound == lowerBound 53 | } else { 54 | return upperBound < lowerBound 55 | } 56 | } else { 57 | return false 58 | } 59 | } 60 | 61 | // 62 | // Methods 63 | // 64 | 65 | public func contains(_ element: Bound) -> Bool { 66 | if let lowerBound = lowerBound { 67 | if let upperBound = upperBound { 68 | if upperBoundClosed { 69 | return element >= lowerBound && element <= upperBound 70 | } else { 71 | return element >= lowerBound && element < upperBound 72 | } 73 | } else { 74 | return element >= lowerBound 75 | } 76 | } else if let upperBound = upperBound { 77 | if upperBoundClosed { 78 | return element <= upperBound 79 | } else { 80 | return element < upperBound 81 | } 82 | } else { 83 | return true 84 | } 85 | } 86 | 87 | @ToString public func description() -> NativeString { 88 | var result = "" 89 | if reversed { 90 | if let upperBound = upperBound { 91 | result = "\(upperBound)" 92 | } 93 | if upperBoundClosed { 94 | if lowerBoundClosed { 95 | result += "..." 96 | } else { 97 | result += "..<" 98 | } 99 | } else { 100 | result += ">.." 101 | } 102 | if let lowerBound = lowerBound { 103 | result += "\(lowerBound)" 104 | } 105 | } else { 106 | if let lowerBound = lowerBound { 107 | result += "\(lowerBound)" 108 | } 109 | if upperBoundClosed { 110 | if lowerBoundClosed { 111 | result += "..." 112 | } else { 113 | result += ">.." 114 | } 115 | } else { 116 | result += "..<" 117 | } 118 | if let upperBound = upperBound { 119 | result += "\(upperBound)" 120 | } 121 | } 122 | return result 123 | } 124 | 125 | #if COCOA 126 | override var debugDescription: NativeString! { 127 | var result = "" 128 | if reversed { 129 | if let upperBound = upperBound { 130 | result = String(reflecting: upperBound) 131 | } 132 | if upperBoundClosed { 133 | result += "..." 134 | } else { 135 | result += ">.." 136 | } 137 | if let lowerBound = lowerBound { 138 | result += String(reflecting: lowerBound) 139 | } 140 | } else { 141 | if let lowerBound = lowerBound { 142 | result += String(reflecting: lowerBound) 143 | } 144 | if upperBoundClosed { 145 | result += "..." 146 | } else { 147 | result += "..<" 148 | } 149 | if let upperBound = upperBound { 150 | result = String(reflecting: upperBound) 151 | } 152 | } 153 | return result 154 | } 155 | #else 156 | var debugDescription: NativeString! { 157 | var result = "" 158 | if reversed { 159 | if let upperBound = upperBound { 160 | result = String(reflecting: upperBound) 161 | } 162 | if upperBoundClosed { 163 | result += "≤..." 164 | } else { 165 | result += "<.." 166 | } 167 | if let lowerBound = lowerBound { 168 | result += String(reflecting: lowerBound) 169 | } 170 | } else { 171 | if let lowerBound = lowerBound { 172 | result += String(reflecting: lowerBound) 173 | } 174 | if upperBoundClosed { 175 | result += "..." 176 | } else { 177 | result += "..<" 178 | } 179 | if let upperBound = upperBound { 180 | result = String(reflecting: upperBound) 181 | } 182 | } 183 | return result 184 | } 185 | #endif 186 | 187 | /* Equatable */ 188 | 189 | public func ==(lhs: Self, rhs: Self) -> Bool { 190 | return lhs.lowerBound == rhs.lowerBound && lhs.upperBound == rhs.upperBound && lhs.upperBoundClosed == rhs.upperBoundClosed 191 | } 192 | 193 | /* IEquatable */ 194 | public func Equals(rhs: /*Self*/Range) -> Bool { // 69955: Silver: two issues wit "Self" vs concrete generic type 195 | return lowerBound == rhs.lowerBound && upperBound == rhs.upperBound && upperBoundClosed == rhs.upperBoundClosed 196 | } 197 | 198 | /* IComparable */ 199 | //func CompareTo(rhs: T) -> Element { 200 | // } 201 | 202 | // 203 | // Subscripts & Iterators 204 | // 205 | 206 | public subscript (i: Bound) -> Bound { 207 | if let lowerBound = lowerBound { 208 | return lowerBound + i 209 | } else { 210 | throw Exception("Cannot random-access \(self) because it has no well-defined lower bound") 211 | } 212 | } 213 | 214 | @Sequence 215 | public func GetSequence() -> ISequence { 216 | if reversed { 217 | if let upperBound = upperBound { 218 | var i = upperBound 219 | if !upperBoundClosed { 220 | i-- 221 | } 222 | if var lowerBound = lowerBound { 223 | if !lowerBoundClosed { 224 | lowerBound++ 225 | } 226 | while i >= lowerBound { 227 | __yield i-- 228 | } 229 | } else { 230 | while i >= 0 { 231 | __yield i-- 232 | } 233 | } 234 | } else { 235 | throw Exception("Cannot iterate over \(self) because it has no well-defined upper bound") 236 | } 237 | } else { 238 | if let lowerBound = lowerBound { 239 | var i = lowerBound 240 | if !lowerBoundClosed { 241 | i++ 242 | } 243 | if let upperBound = upperBound { 244 | if upperBoundClosed { 245 | while i <= upperBound { 246 | __yield i++ 247 | } 248 | } else { 249 | while i < upperBound { 250 | __yield i++ 251 | } 252 | } 253 | } else { 254 | while true { 255 | __yield i++ 256 | } 257 | } 258 | } else { 259 | throw Exception("Cannot iterate over \(self) because it has no well-defined lower bound") 260 | } 261 | } 262 | } 263 | 264 | // 265 | // Silver-specific extensions not defined in standard Swift.Range: 266 | // 267 | 268 | public var length: Bound? { 269 | if let lowerBound = lowerBound, let upperBound = upperBound { 270 | if upperBoundClosed { 271 | return upperBound-lowerBound+1 272 | } else { 273 | return upperBound-lowerBound 274 | } 275 | } 276 | return nil 277 | } 278 | 279 | #if COCOA 280 | public static func __implicit(_ range: Range) -> NSRange { 281 | return range.nativeRange 282 | } 283 | 284 | public static func __implicit(_ range: NSRange) -> Range { 285 | return Range(range.location, range.location+range.length, upperBoundClosed: false) 286 | } 287 | 288 | public var nativeRange: NSRange { 289 | if let lowerBound = lowerBound, upperBound != nil { 290 | return NSMakeRange(lowerBound, length) 291 | } else { 292 | throw Exception("Cannot convert \(self) to NSRange because it has no well-defined lower and upper bounds") 293 | } 294 | } 295 | #endif 296 | 297 | } -------------------------------------------------------------------------------- /Source/Sequence_Functions.swift: -------------------------------------------------------------------------------- 1 | @inline(__always) public func count(_ source: String?) -> Int { 2 | return length(source) 3 | } 4 | 5 | @inline(__always) public func count(_ source: [T]?) -> Int { 6 | if let source = source { 7 | return source.count 8 | } else { 9 | return 0 10 | } 11 | } 12 | 13 | @inline(__always) public func count(_ source: T[]?) -> Int { 14 | return length(source) 15 | } 16 | 17 | @inline(__always) public func count(_ source: ISequence?) -> Int { 18 | if let s = source { 19 | return s.Count() 20 | } 21 | return 0 22 | } 23 | 24 | public func split(_ elements: String, isSeparator: (Char) -> Bool, maxSplit: Int = 0, allowEmptySlices: Bool = false) -> [String] { 25 | 26 | let result = [String]() 27 | var currentString = "" 28 | 29 | func appendCurrent() -> Bool { 30 | if maxSplit > 0 && result.count >= maxSplit { 31 | return false 32 | } 33 | if allowEmptySlices || currentString.length() > 0 { 34 | result.append(currentString) 35 | } 36 | return true 37 | } 38 | 39 | for i in 0 ..< elements.length() { 40 | let ch = elements[i] 41 | if isSeparator(ch) { 42 | if !appendCurrent() { 43 | break 44 | } 45 | currentString = "" 46 | } else { 47 | currentString += ch 48 | } 49 | } 50 | 51 | if currentString.length() > 0 { 52 | appendCurrent() 53 | } 54 | 55 | return result 56 | } 57 | 58 | public func split(_ elements: String, separatorString separator: String) -> [String] { 59 | #if JAVA 60 | return [String](arrayLiteral: (elements as! NativeString).split(java.util.regex.Pattern.quote(separator))) 61 | #elseif CLR 62 | return [String](arrayLiteral: (elements as! NativeString).Split([separator], .None)) 63 | #elseif ISLAND 64 | return [String](arrayLiteral: (elements as! NativeString).Split(separator)) 65 | #elseif COCOA 66 | return [String]((elements as! NativeString).componentsSeparatedByString(separator)) 67 | #endif 68 | } 69 | 70 | public func split(_ elements: String, separatorChar separator: Char) -> [String] { 71 | #if JAVA 72 | return [String](arrayLiteral: (elements as! NativeString).split(java.util.regex.Pattern.quote(java.lang.String.valueOf(separator)))) 73 | #elseif CLR 74 | return [String](arrayLiteral: (elements as! NativeString).Split([separator], .None)) 75 | #elseif ISLAND 76 | return [String](arrayLiteral: (elements as! NativeString).Split(separator)) 77 | #elseif COCOA 78 | return [String]((elements as! NativeString).componentsSeparatedByString(NSString.stringWithFormat("%c", separator))) 79 | #endif 80 | } 81 | 82 | @inline(__always) public func startsWith(_ s: String, `prefix`: String) -> Bool { 83 | return s.hasPrefix(`prefix`) 84 | } 85 | 86 | public func sequence(first: T, next: (T) -> T?) -> ISequence { 87 | var nextResult: T? = first 88 | while nextResult != nil { 89 | __yield nextResult? 90 | nextResult = next(nextResult!) 91 | } 92 | } 93 | 94 | //75374: Swift Compatibility: Cannot use `inout` in closure 95 | /*public func sequence(state: State, next: (inout State) -> T?) -> ISequence { 96 | var nextResult: T? 97 | repeat { 98 | nextResult = next(&state) 99 | if let nextResult = nextResult { 100 | __yield nextResult 101 | } 102 | } while nextResult != nil 103 | }*/ -------------------------------------------------------------------------------- /Source/Sequence_Protocols.swift: -------------------------------------------------------------------------------- 1 |  2 | public typealias ISequenceType = SequenceType 3 | public typealias SequenceType = ISequence 4 | //public protocol ISequence is priovided by the compiler 5 | 6 | public typealias ILazySequenceType = LazySequenceType 7 | public typealias LazySequenceType = ILazySequence 8 | public typealias ILazySequence = ISequence // for now; maybe eventually we'll make non-lazy sequences too 9 | 10 | public typealias IIndexable = Indexable 11 | public protocol Indexable { 12 | associatedtype Index: ForwardIndexType 13 | associatedtype Element 14 | var startIndex: Index { get } 15 | var endIndex: Index { get } 16 | subscript(position: Index) -> Element { get } 17 | } 18 | 19 | public typealias ICollectionType = CollectionType 20 | public protocol CollectionType : Indexable { 21 | associatedtype SubSequence: Indexable, SequenceType = ISequence 22 | subscript(bounds: Range/**/) -> SubSequence { get } 23 | 24 | func `prefix`(upTo: Index) -> SubSequence 25 | func `prefix`(through: Index) -> SubSequence 26 | func suffix(from: Index) -> SubSequence 27 | 28 | var isEmpty: Bool { get } 29 | //74969: Silver: compiler can't see nested associated type from associated type 30 | var count: Int/*Index.Distance*/ { get } 31 | 32 | var first: Element? { get } 33 | } 34 | 35 | public typealias Sliceable = ISliceable 36 | public protocol ISliceable : ICollectionType { 37 | associatedtype SubSlice : Sliceable // 71477: Silver: can't use constraint on type alias in public protocol 38 | subscript (bounds: Range/**/) -> SubSlice { get } // //71476: Silver: can't use "Self." prefix on type aliases in generic public protocol 39 | } -------------------------------------------------------------------------------- /Source/Silver.elements: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | {9E7A4B59-8176-4CAE-B966-7E299171B148} 5 | StaticLibrary 6 | Swift 7 | Release 8 | True 9 | True 10 | True 11 | True 12 | True 13 | 14 | 15 | .\Bin\Debug 16 | True 17 | False 18 | True 19 | DEBUG;TRACE; 20 | 21 | 22 | .\Bin\Release 23 | 24 | 25 | Echoes 26 | .NETFramework4.0 27 | Library 28 | System.Collections.Generic;System.Linq 29 | 30 | 31 | Echoes 32 | .NETStandard2.0 33 | NETSTANDARD 34 | Library 35 | System.Collections.Generic;System.Linq 36 | 37 | 38 | Cooper 39 | Java 40 | Library 41 | java.util,remobjects.elements.linq 42 | 43 | 44 | Island 45 | Windows 46 | 47 | 48 | Island 49 | Linux 50 | 51 | 52 | Island 53 | Darwin 54 | macOS 55 | 10.12 56 | Foundation;RemObjects.Elements.System;rtl 57 | 58 | 59 | Island 60 | Darwin 61 | iOS 62 | 9.0 63 | True 64 | Foundation;RemObjects.Elements.System;rtl 65 | 66 | 67 | Island 68 | Darwin 69 | tvOS 70 | 9.0 71 | Foundation;RemObjects.Elements.System;rtl 72 | 73 | 74 | Island 75 | Darwin 76 | visionOS 77 | 1.0 78 | Foundation;RemObjects.Elements.System;rtl 79 | 80 | 81 | Island 82 | Darwin 83 | watchOS 84 | 3.0 85 | Foundation;RemObjects.Elements.System;rtl 86 | 87 | 88 | Island 89 | Android 90 | 91 | 92 | Island 93 | WebAssembly 94 | 95 | 96 | Toffee 97 | iOS 98 | True 99 | Foundation;RemObjects.Elements.Linq 100 | 101 | 102 | Toffee 103 | macOS 104 | 10.9 105 | Foundation;RemObjects.Elements.Linq 106 | 107 | 108 | Toffee 109 | tvOS 110 | 9.0 111 | Foundation;RemObjects.Elements.Linq 112 | 113 | 114 | Toffee 115 | visionOS 116 | 1.0 117 | Foundation;RemObjects.Elements.Linq 118 | 119 | 120 | Toffee 121 | watchOS 122 | Foundation;RemObjects.Elements.Linq 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | True 134 | 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /Source/Silver.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # RemObjects Fire 4 | Project("{656346D9-4656-40DA-A068-22D5425D4639}") = "Silver", "Silver.elements", "{9E7A4B59-8176-4CAE-B966-7E299171B148}" 5 | EndProject 6 | Project("{656346D9-4656-40DA-A068-22D5425D4639}") = "Swift.Shared", "Swift.Shared.elements", "{7952073B-795C-4074-954D-212FE780D7D3}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|AnyCPU = Debug|AnyCPU 11 | Release|AnyCPU = Release|AnyCPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {9E7A4B59-8176-4CAE-B966-7E299171B148}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU 15 | {9E7A4B59-8176-4CAE-B966-7E299171B148}.Debug|AnyCPU.Build.0 = Debug|AnyCPU 16 | {9E7A4B59-8176-4CAE-B966-7E299171B148}.Release|AnyCPU.ActiveCfg = Release|AnyCPU 17 | {9E7A4B59-8176-4CAE-B966-7E299171B148}.Release|AnyCPU.Build.0 = Release|AnyCPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal -------------------------------------------------------------------------------- /Source/String.Encoding.swift: -------------------------------------------------------------------------------- 1 | #if COCOA 2 | import CoreFoundation 3 | #endif 4 | 5 | public extension SwiftString { 6 | 7 | public struct Encoding { 8 | //76080: Island: error jusing "lazy" 9 | public static /*lazy*/ let ascii: SwiftString.Encoding = Encoding(name: "ASCII") 10 | //public static /*lazy*/ let iso2022JP: SwiftString.Encoding = Encoding() 11 | //public static /*lazy*/ let isoLatin1: SwiftString.Encoding = Encoding() 12 | //public static /*lazy*/ let isoLatin2: SwiftString.Encoding = Encoding() 13 | //public static /*lazy*/ let japaneseEUC: SwiftString.Encoding = Encoding() 14 | //public static /*lazy*/ let macOSRoman: SwiftString.Encoding = Encoding() 15 | //public static /*lazy*/ let nextstep: SwiftString.Encoding = Encoding() 16 | //public static /*lazy*/ let nonLossyASCII: SwiftString.Encoding = Encoding() 17 | //public static /*lazy*/ let shiftJIS: SwiftString.Encoding = Encoding() 18 | //public static /*lazy*/ let symbol: SwiftString.Encoding = Encoding() 19 | //public static /*lazy*/ let unicode: SwiftString.Encoding = Encoding() 20 | public static /*lazy*/ let utf16: SwiftString.Encoding = Encoding(name: "UTF-16") 21 | public static /*lazy*/ let utf16BigEndian: SwiftString.Encoding = Encoding(name: "UTF-16BE") 22 | public static /*lazy*/ let utf16LittleEndian: SwiftString.Encoding = Encoding(name: "UTF-16LE") 23 | public static /*lazy*/ let utf32: SwiftString.Encoding = Encoding(name: "UTF-32") 24 | public static /*lazy*/ let utf32BigEndian: SwiftString.Encoding = Encoding(name: "UTF-32BE") 25 | public static /*lazy*/ let utf32LittleEndian: SwiftString.Encoding = Encoding(name: "UTF-32LE") 26 | public static /*lazy*/ let utf8: SwiftString.Encoding = Encoding(name: "UTF-8") 27 | //public static /*lazy*/ let windowsCP1250: SwiftString.Encoding = Encoding() 28 | //public static /*lazy*/ let windowsCP1251: SwiftString.Encoding = Encoding() 29 | //public static /*lazy*/ let windowsCP1252: SwiftString.Encoding = Encoding() 30 | //public static /*lazy*/ let windowsCP1253: SwiftString.Encoding = Encoding() 31 | //public static /*lazy*/ let windowsCP1254: SwiftString.Encoding = Encoding() 32 | 33 | init(rawValue: NativeEncoding) { 34 | self.rawValue = rawValue 35 | } 36 | 37 | convenience init(name: String) { 38 | init(rawValue: getNativeEncoding(name: name)) 39 | } 40 | 41 | static func getNativeEncoding(name: String) -> NativeEncoding { 42 | #if JAVA 43 | return java.nio.charset.Charset.forName(name) 44 | #elseif CLR 45 | return System.Text.Encoding.GetEncoding(name) 46 | #elseif ISLAND 47 | switch name.uppercased() { 48 | case "UTF8","UTF-8": return RemObjects.Elements.System.Encoding.UTF8 49 | case "UTF16","UTF-16": return RemObjects.Elements.System.Encoding.UTF16 50 | case "UTF32","UTF-32": return RemObjects.Elements.System.Encoding.UTF32 51 | case "UTF16LE","UTF-16LE": return RemObjects.Elements.System.Encoding.UTF16LE 52 | case "UTF16BE","UTF-16BE": return RemObjects.Elements.System.Encoding.UTF16BE 53 | case "UTF32LE","UTF-32LE": return RemObjects.Elements.System.Encoding.UTF32LE 54 | case "UTF32BE","UTF-32BE": return RemObjects.Elements.System.Encoding.UTF32BE 55 | //case "US-ASCII", "ASCII","UTF-ASCII": return RemObjects.Elements.System.Encoding.ASCII 56 | default: throw Exception("Invalid Encoding '\(name)'") 57 | } 58 | #elseif COCOA 59 | switch name.uppercased() { 60 | case "UTF8","UTF-8": return NSStringEncoding.UTF8StringEncoding 61 | case "UTF16","UTF-16": return NSStringEncoding.UTF16StringEncoding 62 | case "UTF32","UTF-32": return NSStringEncoding.UTF32StringEncoding 63 | case "UTF16LE","UTF-16LE": return NSStringEncoding.UTF16LittleEndianStringEncoding 64 | case "UTF16BE","UTF-16BE": return NSStringEncoding.UTF16BigEndianStringEncoding 65 | case "UTF32LE","UTF-32LE": return NSStringEncoding.UTF32LittleEndianStringEncoding 66 | case "UTF32BE","UTF-32BE": return NSStringEncoding.UTF32BigEndianStringEncoding 67 | case "US-ASCII", "ASCII","UTF-ASCII": return NSStringEncoding.ASCIIStringEncoding 68 | default: 69 | let encoding = CFStringConvertIANACharSetNameToEncoding(bridge(name)) 70 | if encoding != kCFStringEncodingInvalidId { 71 | return CFStringConvertEncodingToNSStringEncoding(encoding) as! NSStringEncoding 72 | } 73 | throw Exception("Invalid Encoding '\(name)'") 74 | } 75 | #endif 76 | } 77 | 78 | let rawValue: NativeEncoding 79 | 80 | #if JAVA 81 | typealias NativeEncoding = java.nio.charset.Charset 82 | #elseif CLR 83 | typealias NativeEncoding = System.Text.Encoding 84 | #elseif ISLAND 85 | typealias NativeEncoding = RemObjects.Elements.System.Encoding 86 | #elseif COCOA 87 | typealias NativeEncoding = Foundation.NSStringEncoding 88 | #endif 89 | } 90 | 91 | 92 | } -------------------------------------------------------------------------------- /Source/String.Views.swift: -------------------------------------------------------------------------------- 1 |  2 | public extension SwiftString { 3 | 4 | public __abstract class BaseCharacterView { 5 | internal init { 6 | } 7 | 8 | typealias Index = Int 9 | 10 | public var startIndex: SwiftString.Index { return 0 } 11 | public __abstract var endIndex: SwiftString.Index { get } 12 | 13 | public __abstract var count: Int { get } 14 | public var isEmpty: Bool { return count > 0 } 15 | } 16 | 17 | public class CharacterView: BaseCharacterView { 18 | private let stringData: [Character] 19 | 20 | private init(stringData: [Character]) { 21 | self.stringData = stringData 22 | } 23 | 24 | internal init(string: NativeString) { 25 | stringData = [Character](capacity: length(string)) 26 | 27 | #if JAVA 28 | let it = java.text.BreakIterator.getCharacterInstance(); 29 | it.setText(string); 30 | var start = it.first() 31 | var end = it.next() 32 | while (end != java.text.BreakIterator.DONE) { 33 | stringData.append(Character(nativeStringValue: string.substring(start, end))) 34 | start = end 35 | end = it.next() 36 | } 37 | #elseif CLR 38 | let te = System.Globalization.StringInfo.GetTextElementEnumerator(string) 39 | te.Reset() 40 | while te.MoveNext() { 41 | stringData.append(Character(nativeStringValue: te.Current as! NativeString)) 42 | } 43 | #elseif DARWIN 44 | var i = 0 45 | while i < length(string) { 46 | 47 | let sequenceLength = (string as! NSString).rangeOfComposedCharacterSequenceAtIndex(i).length 48 | 49 | //76192: Silver: can't use range as subscript? (SBL) 50 | let ch: NativeString = string.__substring(range: i ..< i+sequenceLength) 51 | stringData.append(Character(nativeStringValue: ch)) 52 | i += sequenceLength 53 | } 54 | #elseif ISLAND 55 | throw NotImplementedException("CharacterView is not fully implemented for Island yet.") 56 | #hint Not implemented yet 57 | #endif 58 | 59 | /* old logic to detect surrogate pairs; not needed right now 60 | { 61 | let c = string[i] 62 | let c2 = Int(c) 63 | /*switch Int(c) { 64 | case 0x000000...0x00D7FF, 0x00E000...0x00FFFF: 65 | if currenrtSurrogate != nil { 66 | throw Exception("Invalid surrogate pair at index \(i)") 67 | } 68 | currentCharacter = currentCharacter+String(c) 69 | case 0x00D800...0x00DBFF: 70 | if currenrtSurrogate != nil { 71 | throw Exception("Invalid surrogate pair at index \(i)") 72 | } 73 | currentSurrogate = c 74 | case 0x00DC00...0x00DBFF: 75 | if let currenrtSurrogate = currenrtSurrogate { 76 | currentCharacter = currentCharacter+String(currentSurrogate)+String(c) 77 | currentSurrogate = nil 78 | } else { 79 | throw Exception("Invalid surrogate pair at index \(i)") 80 | } 81 | }*/ 82 | if c2 <= 0x0D7FF || c2 > 0x00E000 { 83 | //print(NSString.stringWithFormat("char %x", c2)) 84 | if currentSurrogate != "\0"/*nil*/ { 85 | throw Exception("Invalid surrogate pair at index \(i)") 86 | } 87 | currentCharacter = currentCharacter+String(c) 88 | } else if c2 >= 0x00D800 && c2 <= 0x00DBFF { 89 | //print(NSString.stringWithFormat("s1 %x", c2)) 90 | if currentSurrogate != "\0"/*nil*/ { 91 | throw Exception("Invalid surrogate pair at index \(i)") 92 | } 93 | currentSurrogate = c 94 | } else if c2 >= 0x00DC00 && c2 < 0x00DFFF { 95 | //print(NSString.stringWithFormat("s2 %x", c2)) 96 | if let surrogate = currentSurrogate { 97 | currentCharacter = currentCharacter+surrogate+c 98 | currentSurrogate = "\0"/*nil*/ 99 | } else { 100 | throw Exception("Invalid surrogate pair at index \(i)") 101 | } 102 | } 103 | addCharacter() 104 | 105 | i += 1 106 | } 107 | //addCharacter()*/ 108 | } 109 | 110 | public override var count: Int { return stringData.count } 111 | 112 | public override var endIndex: SwiftString.Index { return stringData.count } 113 | 114 | #if !COOPER 115 | var first: Character? { return count > 0 ? self[0] : nil } 116 | #endif 117 | 118 | func `prefix`(through: Index) -> CharacterView { 119 | return CharacterView(stringData: stringData[0...through]) 120 | } 121 | 122 | func `prefix`(upTo: Index) -> CharacterView { 123 | return CharacterView(stringData: stringData[0.. CharacterView { 127 | return CharacterView(stringData: stringData[from.. CharacterView { 131 | return CharacterView(stringData: stringData[range]) 132 | } 133 | 134 | public subscript(index: Int) -> Character { 135 | return stringData[index] 136 | } 137 | 138 | @ToString public func description() -> NativeString { 139 | var result = "UTF32CharacterView(" 140 | for i in startIndex.. startIndex { 142 | result += " " 143 | } 144 | result += self[i].toHexString() 145 | } 146 | result += ")" 147 | return result 148 | } 149 | } 150 | 151 | public class UTF16View: BaseCharacterView { 152 | private let stringData: NativeString 153 | 154 | internal init(string: NativeString) { 155 | self.stringData = string 156 | } 157 | 158 | public override var count: Int { return length(stringData) } 159 | 160 | public override var endIndex: SwiftString.Index { return length(stringData) } 161 | 162 | // 76085: Silver: `Char` becomes String when using with `?:` operator 163 | var first: UTF16Char? { return count > 0 ? self[0] : nil as? UTF16Char } 164 | 165 | func `prefix`(through: Index) -> UTF16View { 166 | return UTF16View(string: stringData.__substring(range: 0...through)) 167 | } 168 | 169 | func `prefix`(upTo: Index) -> UTF16View { 170 | return UTF16View(string: stringData.__substring(range: 0.. UTF16View { 174 | return UTF16View(string: stringData.__substring(range: from.. UTF16View { 178 | return UTF16View(string: stringData.__substring(range: range)) 179 | } 180 | 181 | public subscript(index: Int) -> UTF16Char { 182 | return stringData[index] 183 | } 184 | 185 | @Sequence 186 | public func GetSequence() -> ISequence { 187 | for i in startIndex ..< endIndex { 188 | __yield self[i] 189 | } 190 | } 191 | 192 | @ToString public func description() -> NativeString { 193 | var result = "UTF16CharacterView(" 194 | for i in startIndex.. startIndex { 196 | result += " " 197 | } 198 | result += UInt16(self[i]).toHexString(length: 4) 199 | } 200 | result += ")" 201 | return result 202 | } 203 | } 204 | 205 | public typealias UnicodeScalarView = UTF32View 206 | 207 | public class UTF32View: BaseCharacterView { 208 | private let stringData: Byte[] 209 | 210 | private init(stringData: Byte[]) { 211 | self.stringData = stringData 212 | } 213 | 214 | internal init(string: NativeString) { 215 | #if JAVA 216 | stringData = string.getBytes("UTF-32LE") 217 | #elseif CLR 218 | stringData = System.Text.UTF32Encoding(/*bigendian:*/false, /*BOM:*/false).GetBytes(string) // todo check order 219 | #elseif ISLAND 220 | stringData = System.Encoding.UTF32LE.GetBytes(string, /*BOM:*/false) // todo check order 221 | #elseif COCOA 222 | if let utf32 = string.dataUsingEncoding(.NSUTF32LittleEndianStringEncoding) { // todo check order 223 | stringData = Byte[](capacity: utf32.length); 224 | utf32.getBytes(stringData, length: utf32.length); 225 | } else { 226 | fatalError("Encoding of SwiftString to UTF32 failed.") 227 | } 228 | #endif 229 | } 230 | 231 | public override var count: Int { return length(stringData) } 232 | 233 | public override var endIndex: SwiftString.Index { 234 | #if COOPER 235 | return remobjects.elements.system.length(stringData)/4 236 | #else 237 | return RemObjects.Elements.System.length(stringData)/4 238 | #endif 239 | } 240 | 241 | var first: UTF32Char? { return count > 0 ? self[0] : nil } 242 | 243 | /*func `prefix`(through: Index) -> UTF32View { 244 | return UTF32View(stringData: stringData[0...through]) 245 | } 246 | 247 | func `prefix`(upTo: Index) -> UTF32View { 248 | return UTF32View(stringData: stringData[0.. UTF32View { 252 | return UTF32View(stringData: stringData[from.. UTF32View { 256 | return UTF32View(stringData: stringData[range]) 257 | }*/ 258 | 259 | public subscript(index: Int) -> UTF32Char { 260 | return stringData[index*4] + stringData[index*4+1]<<8 + stringData[index*4+2]<<16 + stringData[index*4+3]<<24 // todo: check if order is correct 261 | } 262 | 263 | @Sequence 264 | public func GetSequence() -> ISequence { 265 | for i in startIndex ..< endIndex { 266 | __yield self[i] 267 | } 268 | } 269 | 270 | @ToString public func description() -> NativeString { 271 | var result = "UTF32CharacterView(" 272 | for i in startIndex.. startIndex { 274 | result += " " 275 | } 276 | result += UInt32(self[i]).toHexString(length: 8) 277 | } 278 | result += ")" 279 | return result 280 | } 281 | } 282 | 283 | public class UTF8View: BaseCharacterView { 284 | internal let stringData: UTF8Char[] 285 | 286 | private init(stringData: UTF8Char[]) { 287 | self.stringData = stringData 288 | } 289 | 290 | internal init(string: NativeString) { 291 | #if JAVA 292 | stringData = string.getBytes("UTF-8"); 293 | #elseif CLR 294 | stringData = System.Text.UTF8Encoding(/*BOM:*/false).GetBytes(string) 295 | #elseif ISLAND 296 | stringData = System.Encoding.UTF8.GetBytes(string, /*BOM:*/false) as! UTF8Char[] 297 | #elseif COCOA 298 | if let utf8 = string.dataUsingEncoding(.NSUTF8StringEncoding) { 299 | stringData = UTF8Char[](capacity: utf8.length); 300 | utf8.getBytes(stringData, length: utf8.length); 301 | } else { 302 | fatalError("Encoding of String to UTF8 failed.") 303 | } 304 | #endif 305 | } 306 | 307 | public override var count: Int { return length(stringData) } 308 | 309 | public override var endIndex: SwiftString.Index { 310 | #if COOPER 311 | return remobjects.elements.system.length(stringData) 312 | #else 313 | return RemObjects.Elements.System.length(stringData) 314 | #endif 315 | } 316 | 317 | var first: UTF8Char? { return count > 0 ? self[0] : nil } 318 | 319 | /*func `prefix`(through: Index) -> UTF8View { 320 | return UTF8View(stringData: stringData[0...through]) 321 | } 322 | 323 | func `prefix`(upTo: Index) -> UTF8View { 324 | return UTF8View(stringData: stringData[0.. UTF8View { 328 | return UTF8View(stringData: stringData[from.. UTF8View { 332 | return UTF8View(stringData: stringData[range]) 333 | }*/ 334 | 335 | public subscript(index: Int) -> UTF8Char { 336 | return stringData[index] 337 | } 338 | 339 | @Sequence 340 | public func GetSequence() -> ISequence { 341 | return stringData 342 | } 343 | 344 | @ToString public func description() -> NativeString { 345 | var result = "UTF8CharacterView(" 346 | for i in startIndex.. startIndex { 348 | result += " " 349 | } 350 | result += UInt64(self[i]).toHexString(length: 2) 351 | } 352 | result += ")" 353 | return result 354 | } 355 | } 356 | } -------------------------------------------------------------------------------- /Source/String_Extensions.swift: -------------------------------------------------------------------------------- 1 | public extension NativeString /*: Streamable*/ { 2 | 3 | typealias Index = Int 4 | 5 | public init(repeating c: Char, count: Int) { 6 | 7 | #if JAVA || ISLAND 8 | var chars = Char[](count) 9 | for i in 0 ..< count { 10 | chars[i] = c 11 | } 12 | return NativeString(chars) 13 | #elseif CLR 14 | return NativeString(c, count) 15 | #elseif COCOA 16 | return "".stringByPaddingToLength(count, withString: NSString.stringWithFormat("%c", c), startingAtIndex: 0) 17 | #endif 18 | } 19 | 20 | public init(_ c: Char) { 21 | return NativeString(repeating: c, count: 1) 22 | } 23 | 24 | public init(_ object: Object) { 25 | if let o = object as? ICustomStringConvertible { 26 | return o.description 27 | } else { 28 | #if JAVA 29 | return object.toString() 30 | #elseif CLR || ISLAND 31 | return object.ToString() 32 | #elseif COCOA 33 | return object.description 34 | #endif 35 | } 36 | } 37 | 38 | public convenience init(describing subject: Object) { 39 | /*if let instance = subject as? ITextOutputStreamable { 40 | instance.write(to: ) 41 | } else*/ if let instance = subject as? ICustomStringConvertible { 42 | return instance.description 43 | } else if let instance = subject as? CustomDebugStringConvertible { 44 | return instance.debugDescription 45 | } else { 46 | return init(subject) 47 | } 48 | } 49 | 50 | public convenience init(reflecting subject: Object) { 51 | if let o = subject as? ICustomDebugStringConvertible { 52 | return o.debugDescription 53 | } else if let instance = subject as? ICustomStringConvertible { 54 | return instance.description 55 | //} else if let instance = subject as? ITextOutputStreamable { 56 | //instance.write(to: ) 57 | } else { 58 | #if JAVA 59 | // ToDo: fall back to reflection to call debugDescription? 60 | // ToDo: fall back to checking for extension methods 61 | #elseif CLR 62 | // ToDo: fall back to reflection to call debugDescription? 63 | // ToDo: fall back to checking for extension methods 64 | #elseif COCOA 65 | if subject.respondsToSelector(#selector(debugDescription)) { 66 | return subject.debugDescription 67 | } 68 | // ToDo: fall back to checking for extension methods 69 | #endif 70 | } 71 | 72 | return init(subject) 73 | } 74 | 75 | // 76 | // Properties 77 | // 78 | 79 | public var characters: SwiftString.CharacterView { 80 | return SwiftString.CharacterView(string: self) 81 | } 82 | 83 | #if !COCOA 84 | public var debugDescription: NativeString { 85 | return self 86 | } 87 | #endif 88 | 89 | public var endIndex: NativeString.Index { 90 | #if CLR 91 | return self.Length 92 | #else 93 | return self.length() 94 | #endif 95 | } 96 | 97 | public var hashValue: Int { 98 | #if JAVA 99 | return self.hashCode() 100 | #elseif CLR || ISLAND 101 | return self.GetHashCode() 102 | #elseif COCOA 103 | return self.hashValue() 104 | #endif 105 | } 106 | 107 | public var isEmpty : Bool { 108 | #if JAVA 109 | return self.isEmpty() 110 | #elseif CLR || ISLAND 111 | return NativeString.IsNullOrEmpty(self) 112 | #elseif COCOA 113 | return length == 0 114 | #endif 115 | } 116 | 117 | public func lowercased() -> NativeString { 118 | #if JAVA 119 | return self.toLowerCase() 120 | #elseif CLR || ISLAND 121 | return self.ToLower() 122 | #elseif COCOA 123 | return self.lowercaseString 124 | #endif 125 | } 126 | 127 | #if COCOA 128 | /*public var nulTerminatedUTF8: Character[] { 129 | return cStringUsingEncoding(.UTF8StringEncoding) // E62 Type mismatch, cannot assign "UnsafePointer" to "Character[]" 130 | }*/ 131 | #endif 132 | 133 | public var startIndex: NativeString.Index { 134 | return 0 135 | } 136 | 137 | //public var capitalized: NativeString { 138 | ////return uppercaseString 139 | //} 140 | 141 | //func components(separatedBy separator: CharacterSet) -> [String] { 142 | //} 143 | 144 | public func components(separatedBy separator: String) -> [String] { 145 | let separatorLength = separator.length() 146 | if separatorLength == 0 { 147 | return [self] 148 | } 149 | 150 | #if COOPER 151 | //exit nativeString.split(java.util.regex.Pattern.quote(Separator)) as not nullable 152 | //Custom implementation because `mapped.split` strips empty parts at the end, making it incompatible with the other three platfroms. 153 | var result = [String]() 154 | var i = 0 155 | while true { 156 | let p = indexOf(separator, i) 157 | if p > -1 { 158 | let part = substring(i, p-i) 159 | result.append(part) 160 | i = p+separatorLength 161 | } else { 162 | let part = substring(i) 163 | result.append(part) 164 | break 165 | } 166 | } 167 | return result 168 | #elseif ECHOES 169 | return [String](Split([separator], StringSplitOptions.None).ToList()) 170 | #elseif ISLAND 171 | return [String](Split(separator).ToList()) 172 | #elseif TOFFEE 173 | return [String](componentsSeparatedByString(separator)) 174 | #endif 175 | } 176 | 177 | public func uppercased() -> NativeString { 178 | #if JAVA 179 | return self.toUpperCase() 180 | #elseif TOFFEE 181 | return uppercaseString 182 | #elseif CLR || ISLAND 183 | return self.ToUpper() 184 | #endif 185 | } 186 | 187 | public var utf8: SwiftString.UTF8View { 188 | return SwiftString.UTF8View(string: self) 189 | } 190 | 191 | public var utf16: SwiftString.UTF16View { 192 | return SwiftString.UTF16View(string: self) 193 | } 194 | 195 | public var unicodeScalars: SwiftString.UnicodeScalarView { 196 | return SwiftString.UnicodeScalarView(string: self) 197 | } 198 | 199 | // 200 | // Methods 201 | // 202 | 203 | #if !COCOA 204 | public func hasPrefix(_ `prefix`: NativeString) -> Bool { 205 | #if JAVA 206 | return startsWith(`prefix`) 207 | #elseif CLR || ISLAND 208 | return StartsWith(`prefix`) 209 | #endif 210 | } 211 | 212 | public func hasSuffix(_ suffix: NativeString) -> Bool { 213 | #if JAVA 214 | return endsWith(suffix) 215 | #elseif CLR || ISLAND 216 | return EndsWith(suffix) 217 | #endif 218 | } 219 | #endif 220 | 221 | #if COCOA 222 | public static func fromCString(cs: UnsafePointer) -> NativeString? { 223 | if cs == nil { 224 | return nil 225 | } 226 | return NSString.stringWithUTF8String(cs) 227 | } 228 | 229 | public static func fromCStringRepairingIllFormedUTF8(_ cs: UnsafePointer) -> (NativeString?, /*hadError:*/ Bool) { 230 | if cs == nil { 231 | return (nil, false) 232 | } 233 | //todo: If CString contains ill-formed UTF-8 code unit sequences, replaces them with replacement characters (U+FFFD). 234 | return (NSString.stringWithUTF8String(cs), false) 235 | } 236 | #endif 237 | 238 | #if !ISLAND 239 | public func withUTF8Buffer(@noescape _ body: (/*UnsafeBufferPointer*/UTF8Char[]) -> R) -> R { 240 | return body(utf8.stringData) 241 | } 242 | #endif 243 | 244 | // 245 | // Subscripts 246 | // 247 | 248 | public func `prefix`(through: Index) -> NativeString { 249 | return self[...through] // E119 Cannot use the unary operator "..." on type "extension String.Index" 250 | } 251 | 252 | public func `prefix`(upTo: Index) -> NativeString { 253 | return self[.. NativeString { 257 | return self[from...] 258 | } 259 | 260 | //public subscript(range: NativeString.Index) -> Character // implicitly provided by the compiler, already 261 | 262 | //76192: Silver: can't use range as subscript? (SBL) 263 | public subscript(_ range: Range/**/) -> NativeString { 264 | return __substring(range: range) 265 | } 266 | 267 | internal func __substring(range: Range/**/) -> NativeString { 268 | if range.upperBound != nil { 269 | #if JAVA 270 | return substring(coalesce(range.lowerBound, 0), range.length) 271 | #elseif CLR || ISLAND 272 | return Substring(coalesce(range.lowerBound, 0), range.length) 273 | #elseif COCOA 274 | if range.lowerBound != nil { 275 | return substringWithRange(range.nativeRange) // todo: make a cast operator 276 | } else { 277 | return substringToIndex(range.length) 278 | } 279 | #endif 280 | } else if let lowerBound = range.lowerBound { 281 | #if JAVA 282 | return substring(lowerBound) 283 | #elseif CLR || ISLAND 284 | return Substring(lowerBound) 285 | #elseif COCOA 286 | return substringFromIndex(lowerBound) 287 | #endif 288 | } else { 289 | return self 290 | } 291 | } 292 | 293 | // Streamable 294 | func writeTo(_ target: OutputStreamType) { 295 | //target.write(self) 296 | } 297 | 298 | // 299 | // Silver-specific extensions not defined in standard Swift.NativeString: 300 | // 301 | 302 | #if !COCOA && !JAVA 303 | public func length() -> Int { 304 | #if CLR 305 | return self.Length 306 | #else 307 | return self.length() 308 | #endif 309 | } 310 | #endif 311 | 312 | public func toInt() -> Int? { 313 | #if JAVA 314 | __try { 315 | return Integer.parseInt(self) 316 | } __catch E: NumberFormatException { 317 | return nil 318 | } 319 | #elseif CLR || ISLAND 320 | var i = 0 321 | if Int64.TryParse(self, &i) { 322 | return i 323 | } 324 | return nil 325 | #elseif COCOA 326 | let formatter = NSNumberFormatter() 327 | formatter.numberStyle = .NSNumberFormatterOrdinalStyle 328 | if let number = formatter.numberFromString(self) { 329 | return number.integerValue 330 | } 331 | return nil 332 | #endif 333 | } 334 | } -------------------------------------------------------------------------------- /Source/Swift.Cooper.elements: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 3.5 5 | {399BE68A-44C3-4357-8D11-4B64C6EC0674} 6 | Library 7 | Release 8 | False 9 | Swift 10 | JW0 11 | java.util,remobjects.elements.linq 12 | True 13 | silver 14 | 15 | 16 | .\bin\Debug 17 | DEBUG;TRACE; 18 | True 19 | True 20 | False 21 | Project 22 | False 23 | anycpu 24 | v25 25 | True 26 | False 27 | 28 | 29 | bin\Release\ 30 | False 31 | Project 32 | False 33 | anycpu 34 | v25 35 | True 36 | False 37 | JW0 38 | WarningOnPublicMembers 39 | False 40 | 41 | 42 | 43 | 44 | True 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /Source/Swift.Echoes.Standard.elements: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 3.5 5 | Swift 6 | {CDDEBE6E-6B6B-4EF7-B2E1-57239C443426} 7 | Library 8 | False 9 | False 10 | False 11 | False 12 | False 13 | Release 14 | System.Collections.Generic;System.Linq 15 | .NETStandard2.0 16 | Silver 17 | 18 | 19 | false 20 | .\bin\Debug 21 | DEBUG;TRACE; 22 | True 23 | True 24 | True 25 | False 26 | False 27 | Project 28 | False 29 | anycpu 30 | v25 31 | False 32 | WarningOnPublicMembers 33 | False 34 | True 35 | 36 | 37 | true 38 | .\bin\Release 39 | True 40 | True 41 | False 42 | False 43 | False 44 | Project 45 | False 46 | anycpu 47 | v25 48 | False 49 | WarningOnPublicMembers 50 | False 51 | True 52 | SIGN 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /Source/Swift.Echoes.elements: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 3.5 5 | Swift 6 | {BAE82ECC-39A5-4A18-9CE1-EAC0653F6E0F} 7 | Library 8 | False 9 | False 10 | False 11 | False 12 | False 13 | Release 14 | v4.0 15 | System.Collections.Generic;System.Linq 16 | Silver 17 | 18 | 19 | false 20 | .\bin\Debug 21 | DEBUG;TRACE; 22 | True 23 | True 24 | True 25 | False 26 | False 27 | Project 28 | False 29 | anycpu 30 | v25 31 | False 32 | WarningOnPublicMembers 33 | False 34 | True 35 | 36 | 37 | true 38 | .\bin\Release 39 | True 40 | True 41 | False 42 | False 43 | False 44 | Project 45 | False 46 | anycpu 47 | v25 48 | False 49 | WarningOnPublicMembers 50 | False 51 | True 52 | SIGN 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /Source/Swift.Island.Android.elements: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 3.5 5 | Swift 6 | {FA456B74-3E30-45ED-91B2-6BB7A104F836} 7 | StaticLibrary 8 | False 9 | False 10 | False 11 | False 12 | False 13 | Release 14 | Silver 15 | 16 | 17 | false 18 | .\bin\Debug 19 | DEBUG;TRACE; 20 | True 21 | True 22 | False 23 | False 24 | Project 25 | False 26 | anycpu 27 | v25 28 | False 29 | WarningOnPublicMembers 30 | False 31 | True 32 | 33 | 34 | true 35 | .\bin\Release 36 | True 37 | False 38 | False 39 | False 40 | Project 41 | False 42 | anycpu 43 | v25 44 | False 45 | WarningOnPublicMembers 46 | False 47 | True 48 | SIGN 49 | arm64-v8a;armeabi;armeabi-v7a;x86;x86_64 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /Source/Swift.Island.Darwin.iOS.elements: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 3.5 5 | Swift 6 | {6F87C50F-069A-4E56-9B2E-044CBB68CC83} 7 | StaticLibrary 8 | False 9 | False 10 | False 11 | False 12 | False 13 | Release 14 | Foundation;RemObjects.Elements.System;rtl 15 | iOS 16 | True 17 | Silver 18 | 9.0 19 | 20 | 21 | false 22 | .\bin\Debug 23 | DEBUG;TRACE; 24 | True 25 | True 26 | False 27 | False 28 | Project 29 | False 30 | anycpu 31 | v25 32 | False 33 | WarningOnPublicMembers 34 | False 35 | True 36 | 37 | 38 | true 39 | .\bin\Release 40 | True 41 | False 42 | False 43 | False 44 | Project 45 | False 46 | anycpu 47 | v25 48 | False 49 | WarningOnPublicMembers 50 | False 51 | True 52 | SIGN 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /Source/Swift.Island.Darwin.macOS.elements: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 3.5 5 | Swift 6 | {792E19D0-3F6B-4EF5-A113-87C76EB0CE5E} 7 | StaticLibrary 8 | False 9 | False 10 | False 11 | False 12 | False 13 | Release 14 | Foundation;RemObjects.Elements.System;rtl 15 | macOS 16 | Silver 17 | 10.12 18 | 19 | 20 | false 21 | .\bin\Debug 22 | DEBUG;TRACE; 23 | True 24 | True 25 | False 26 | False 27 | Project 28 | False 29 | anycpu 30 | v25 31 | False 32 | WarningOnPublicMembers 33 | False 34 | True 35 | 36 | 37 | true 38 | .\bin\Release 39 | True 40 | False 41 | False 42 | False 43 | Project 44 | False 45 | anycpu 46 | v25 47 | False 48 | WarningOnPublicMembers 49 | False 50 | True 51 | SIGN 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Source/Swift.Island.Darwin.tvOS.elements: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 3.5 5 | Swift 6 | {A037C663-4495-4630-A9EF-39079BA1EC07} 7 | StaticLibrary 8 | False 9 | False 10 | False 11 | False 12 | False 13 | Release 14 | Foundation;RemObjects.Elements.System;rtl 15 | tvOS 16 | Silver 17 | 9.0 18 | 19 | 20 | false 21 | .\bin\Debug 22 | DEBUG;TRACE; 23 | True 24 | True 25 | False 26 | False 27 | Project 28 | False 29 | anycpu 30 | v25 31 | False 32 | WarningOnPublicMembers 33 | False 34 | True 35 | 36 | 37 | true 38 | .\bin\Release 39 | True 40 | False 41 | False 42 | False 43 | Project 44 | False 45 | anycpu 46 | v25 47 | False 48 | WarningOnPublicMembers 49 | False 50 | True 51 | SIGN 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Source/Swift.Island.Darwin.watchOS.elements: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 3.5 5 | Swift 6 | {B9065575-47D6-4740-8D96-D8F5A1A30B0B} 7 | StaticLibrary 8 | False 9 | False 10 | False 11 | False 12 | False 13 | Release 14 | Foundation;RemObjects.Elements.System;rtl 15 | watchOS 16 | Silver 17 | 3.0 18 | 19 | 20 | false 21 | .\bin\Debug 22 | DEBUG;TRACE; 23 | True 24 | True 25 | False 26 | False 27 | Project 28 | False 29 | anycpu 30 | v25 31 | False 32 | WarningOnPublicMembers 33 | False 34 | True 35 | 36 | 37 | true 38 | .\bin\Release 39 | True 40 | False 41 | False 42 | False 43 | Project 44 | False 45 | anycpu 46 | v25 47 | False 48 | WarningOnPublicMembers 49 | False 50 | True 51 | SIGN 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Source/Swift.Island.Linux.elements: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 3.5 5 | Swift 6 | {A764B9EF-BE23-43AE-ACEB-43F24F45EAE9} 7 | StaticLibrary 8 | False 9 | False 10 | False 11 | False 12 | False 13 | Release 14 | Silver 15 | 16 | 17 | false 18 | .\bin\Debug 19 | DEBUG;TRACE; 20 | True 21 | True 22 | False 23 | False 24 | Project 25 | False 26 | anycpu 27 | v25 28 | False 29 | WarningOnPublicMembers 30 | False 31 | True 32 | 33 | 34 | true 35 | .\bin\Release 36 | True 37 | False 38 | False 39 | False 40 | Project 41 | False 42 | anycpu 43 | v25 44 | False 45 | WarningOnPublicMembers 46 | False 47 | True 48 | SIGN 49 | x86_64;armv6 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /Source/Swift.Island.WebAssembly.elements: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 3.5 5 | Swift 6 | {D38B4354-35C8-4BC9-9415-4D72A1F77CA1} 7 | StaticLibrary 8 | False 9 | False 10 | False 11 | False 12 | False 13 | Release 14 | Silver 15 | 16 | 17 | false 18 | .\bin\Debug 19 | DEBUG;TRACE; 20 | True 21 | True 22 | False 23 | False 24 | Project 25 | False 26 | anycpu 27 | v25 28 | False 29 | WarningOnPublicMembers 30 | False 31 | True 32 | 33 | 34 | true 35 | .\bin\Release 36 | True 37 | False 38 | False 39 | False 40 | Project 41 | False 42 | anycpu 43 | v25 44 | False 45 | WarningOnPublicMembers 46 | False 47 | True 48 | SIGN 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /Source/Swift.Island.Windows.elements: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 3.5 5 | Swift 6 | {D32E206A-1255-4DA9-8287-64E5E988ABA4} 7 | StaticLibrary 8 | False 9 | False 10 | False 11 | False 12 | False 13 | Release 14 | Silver 15 | 16 | 17 | false 18 | .\bin\Debug 19 | DEBUG;TRACE; 20 | True 21 | True 22 | False 23 | False 24 | Project 25 | False 26 | anycpu 27 | v25 28 | False 29 | WarningOnPublicMembers 30 | False 31 | True 32 | 33 | 34 | true 35 | .\bin\Release 36 | True 37 | False 38 | False 39 | False 40 | Project 41 | False 42 | anycpu 43 | v25 44 | False 45 | WarningOnPublicMembers 46 | False 47 | True 48 | SIGN 49 | x86_64;i386 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /Source/Swift.Shared.elements: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 7952073B-795C-4074-954D-212FE780D7D3 5 | Swift.Shared 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Source/Swift.Shared.projitems: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | 7952073B-795C-4074-954D-212FE780D7D3 7 | Swift.Shared 8 | {7952073B-795C-4074-954D-212FE780D7D3} 9 | 10 | 11 | 12 | 13 | Sequences 14 | 15 | 16 | 17 | Collection Types 18 | 19 | 20 | 21 | Collection Types 22 | 23 | 24 | 25 | Numbers and such 26 | 27 | 28 | 29 | Collection Types 30 | 31 | 32 | String 33 | 34 | 35 | String 36 | 37 | 38 | 39 | Sequences 40 | 41 | 42 | 43 | Sequences 44 | 45 | 46 | 47 | 48 | Numbers and such 49 | 50 | 51 | Collection Types 52 | 53 | 54 | Numbers and such 55 | 56 | 57 | Numbers and such 58 | 59 | 60 | Numbers and such 61 | 62 | 63 | Sequences 64 | 65 | 66 | 67 | 68 | String 69 | 70 | 71 | String 72 | 73 | 74 | String 75 | 76 | 77 | String 78 | 79 | 80 | 81 | Cocoa 82 | 83 | 84 | Cocoa 85 | 86 | 87 | Numbers and such 88 | 89 | 90 | Numbers and such 91 | 92 | 93 | 94 | 95 | 96 | 97 | Memory 98 | 99 | 100 | Memory 101 | 102 | 103 | Memory 104 | 105 | 106 | Sequences 107 | 108 | 109 | 110 | 111 | True 112 | 113 | 114 | True 115 | 116 | 117 | True 118 | 119 | 120 | True 121 | 122 | 123 | True 124 | 125 | 126 | True 127 | 128 | 129 | -------------------------------------------------------------------------------- /Source/Swift.Toffee.iOS.elements: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Swift 5 | {95F9545C-39BE-4A02-8673-8382ECB3F7AD} 6 | StaticLibrary 7 | False 8 | False 9 | False 10 | False 11 | False 12 | Release 13 | iOS 14 | True 15 | Foundation,RemObjects.Elements.Linq 16 | 9.0 17 | True 18 | NW6 19 | True 20 | Silver 21 | 22 | 23 | false 24 | .\bin\Debug 25 | DEBUG;TRACE; 26 | True 27 | True 28 | False 29 | False 30 | True 31 | 32 | 33 | true 34 | .\bin\Release 35 | True 36 | False 37 | False 38 | False 39 | True 40 | True 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /Source/Swift.Toffee.macOS.elements: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Swift 5 | {8F87CCEF-C142-49A8-8828-32211B2CBFBE} 6 | StaticLibrary 7 | False 8 | False 9 | False 10 | False 11 | False 12 | Release 13 | macOS 14 | True 15 | Foundation,RemObjects.Elements.Linq 16 | 10.12 17 | True 18 | DEBUG;OLD_DEPLOYMENT_TARGET;TRACE 19 | NW6 20 | Silver 21 | 22 | 23 | false 24 | .\bin\Debug 25 | DEBUG;TRACE 26 | True 27 | True 28 | False 29 | False 30 | True 31 | 32 | 33 | true 34 | .\bin\Release 35 | True 36 | False 37 | False 38 | False 39 | True 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /Source/Swift.Toffee.tvOS.elements: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Swift 5 | {EA152C1C-C6DD-48F8-9415-8B7FDA4653D9} 6 | StaticLibrary 7 | False 8 | False 9 | False 10 | False 11 | False 12 | Release 13 | tvOS 14 | True 15 | Foundation,RemObjects.Elements.Linq 16 | 9.0 17 | True 18 | NW6 19 | Silver 20 | 21 | 22 | false 23 | .\bin\Debug 24 | DEBUG;TRACE; 25 | True 26 | True 27 | False 28 | False 29 | True 30 | 31 | 32 | true 33 | .\bin\Release 34 | True 35 | False 36 | False 37 | False 38 | True 39 | True 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /Source/Swift.Toffee.watchOS.elements: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Swift 5 | {E0C9DDDB-B83F-4164-ADE4-577FB6611F3F} 6 | StaticLibrary 7 | False 8 | False 9 | False 10 | False 11 | False 12 | Release 13 | watchOS 14 | True 15 | Foundation,RemObjects.Elements.Linq 16 | 3.0 17 | True 18 | NW6 19 | Silver 20 | 21 | 22 | false 23 | .\bin\Debug 24 | DEBUG;TRACE; 25 | True 26 | True 27 | False 28 | False 29 | True 30 | 31 | 32 | true 33 | .\bin\Release 34 | True 35 | False 36 | False 37 | False 38 | True 39 | True 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /Source/SwiftBaseLibrary.licenses: -------------------------------------------------------------------------------- 1 | 983bc8e858fa9303be61e14dfd7b054ce7cbe367114f1c076a80b7058c54fcc414b7212eec848c1baeb1e041b51059c34884240dfd339f53054b9ecb8127e80e71919e975bac9eb89dad2eba4792fac20c15d6dc7657834eaa12e3b096107f09a387609fb4541e82e965a5fb777cb6ed8988c8d07be9384a366f0e518f588cad1078c7ea65e032e95b06e2fdc36e941efeba2fa13a6d5d344c08335b8d583dd86f2281c611600a5ca45287f122ee414a169851610ea504a318ba59a7cc7379f8a8278fd24bedbdde3450b96705ead1e5c124ba5d371f1acb850bf4cb8ee43b351f6f52357b8e1fdbd6761a0cef28b5d5d0296c515126d3a41c4767eff9accbef 2 | a625afe1c94b05e026fa97ead5c8a1b6e999f1c80e2d692923e68f0d85678a12eef1ab1dfbcfe65e44923029f160514e89db479169a157ec3c29382f1c46db56093566eb24db0495eb6cf61dd20ca6f93fbab5653b5133586cabdeb8d55a16c1ea14b1ffefc7479e02ab7d0febd5beeb90cf4a4f93a69aa1aab61908e4238f15 3 | [License] 4 | LicenseType=Project 5 | Product=Oxygene 6 | Platform=Cooper 7 | AllowBeta=1 8 | AllowFull=1 9 | 10 | DisplayName=SwiftBaseLibrary Contributor License, Oxygene/Cooper 11 | ProjectName=Swift.Cooper 12 | ProjectFileName=Swift.Cooper.elements 13 | ProjectGuid=399be68a-44c3-4357-8d11-4b64c6ec0674 14 | ProjectAssemblyName=swift 15 | ProjectOutputType=Library 16 | 17 | [License] 18 | LicenseType=Project 19 | Product=Silver 20 | Platform=Cooper 21 | AllowBeta=1 22 | AllowFull=1 23 | 24 | DisplayName=SwiftBaseLibrary Contributor License, Silver/Cooper 25 | ProjectName=Swift.Cooper 26 | ProjectFileName=Swift.Cooper.elements 27 | ProjectGuid=399be68a-44c3-4357-8d11-4b64c6ec0674 28 | ProjectAssemblyName=swift 29 | ProjectOutputType=Library 30 | 31 | [License] 32 | LicenseType=Project 33 | Product=Oxygene 34 | Platform=Echoes 35 | AllowBeta=1 36 | AllowFull=1 37 | 38 | DisplayName=SwiftBaseLibrary Contributor License, Oxygene/Echoes 39 | ProjectName=Swift.Echoes 40 | ProjectFileName=Swift.Echoes.elements 41 | ProjectGuid=bae82ecc-39a5-4a18-9ce1-eac0653f6e0f 42 | ProjectAssemblyName=Swift 43 | ProjectOutputType=Library 44 | 45 | [License] 46 | LicenseType=Project 47 | Product=Silver 48 | Platform=Echoes 49 | AllowBeta=1 50 | AllowFull=1 51 | 52 | DisplayName=SwiftBaseLibrary Contributor License, Silver/Echoes 53 | ProjectName=Swift.Echoes 54 | ProjectFileName=Swift.Echoes.elements 55 | ProjectGuid=bae82ecc-39a5-4a18-9ce1-eac0653f6e0f 56 | ProjectAssemblyName=Swift 57 | ProjectOutputType=Library 58 | 59 | [License] 60 | LicenseType=Project 61 | Product=Oxygene 62 | Platform=Island 63 | AllowBeta=1 64 | AllowFull=1 65 | 66 | DisplayName=SwiftBaseLibrary Contributor License, Oxygene/Island 67 | ProjectName=Swift.Island.Android 68 | ProjectFileName=Swift.Island.Android.elements 69 | ProjectGuid={fa456b74-3e30-45ed-91b2-6bb7a104f836} 70 | ProjectAssemblyName=Swift 71 | ProjectOutputType=StaticLibrary 72 | 73 | [License] 74 | LicenseType=Project 75 | Product=Silver 76 | Platform=Island 77 | AllowBeta=1 78 | AllowFull=1 79 | 80 | DisplayName=SwiftBaseLibrary Contributor License, Silver/Island 81 | ProjectName=Swift.Island.Android 82 | ProjectFileName=Swift.Island.Android.elements 83 | ProjectGuid={fa456b74-3e30-45ed-91b2-6bb7a104f836} 84 | ProjectAssemblyName=Swift 85 | ProjectOutputType=StaticLibrary 86 | 87 | [License] 88 | LicenseType=Project 89 | Product=Oxygene 90 | Platform=Island 91 | AllowBeta=1 92 | AllowFull=1 93 | 94 | DisplayName=SwiftBaseLibrary Contributor License, Oxygene/Island 95 | ProjectName=Swift.Island.Linux 96 | ProjectFileName=Swift.Island.Linux.elements 97 | ProjectGuid={a764b9ef-be23-43ae-aceb-43f24f45eae9} 98 | ProjectAssemblyName=Swift 99 | ProjectOutputType=StaticLibrary 100 | 101 | [License] 102 | LicenseType=Project 103 | Product=Silver 104 | Platform=Island 105 | AllowBeta=1 106 | AllowFull=1 107 | 108 | DisplayName=SwiftBaseLibrary Contributor License, Silver/Island 109 | ProjectName=Swift.Island.Linux 110 | ProjectFileName=Swift.Island.Linux.elements 111 | ProjectGuid={a764b9ef-be23-43ae-aceb-43f24f45eae9} 112 | ProjectAssemblyName=Swift 113 | ProjectOutputType=StaticLibrary 114 | 115 | [License] 116 | LicenseType=Project 117 | Product=Oxygene 118 | Platform=Island 119 | AllowBeta=1 120 | AllowFull=1 121 | 122 | DisplayName=SwiftBaseLibrary Contributor License, Oxygene/Island 123 | ProjectName=Swift.Island.Windows 124 | ProjectFileName=Swift.Island.Windows.elements 125 | ProjectGuid={d32e206a-1255-4da9-8287-64e5e988aba4} 126 | ProjectAssemblyName=Swift 127 | ProjectOutputType=StaticLibrary 128 | 129 | [License] 130 | LicenseType=Project 131 | Product=Silver 132 | Platform=Island 133 | AllowBeta=1 134 | AllowFull=1 135 | 136 | DisplayName=SwiftBaseLibrary Contributor License, Silver/Island 137 | ProjectName=Swift.Island.Windows 138 | ProjectFileName=Swift.Island.Windows.elements 139 | ProjectGuid={d32e206a-1255-4da9-8287-64e5e988aba4} 140 | ProjectAssemblyName=Swift 141 | ProjectOutputType=StaticLibrary 142 | 143 | [License] 144 | LicenseType=Project 145 | Product=Oxygene 146 | Platform=Cooper 147 | AllowBeta=1 148 | AllowFull=1 149 | 150 | DisplayName=SwiftBaseLibrary Contributor License, Oxygene/Cooper 151 | ProjectName=Swift.Shared 152 | ProjectFileName=Swift.Shared.elements 153 | ProjectGuid=7952073b-795c-4074-954d-212fe780d7d3 154 | ProjectAssemblyName=Swift.Shared 155 | ProjectOutputType=Shared 156 | 157 | [License] 158 | LicenseType=Project 159 | Product=Oxygene 160 | Platform=Echoes 161 | AllowBeta=1 162 | AllowFull=1 163 | 164 | DisplayName=SwiftBaseLibrary Contributor License, Oxygene/Echoes 165 | ProjectName=Swift.Shared 166 | ProjectFileName=Swift.Shared.elements 167 | ProjectGuid=7952073b-795c-4074-954d-212fe780d7d3 168 | ProjectAssemblyName=Swift.Shared 169 | ProjectOutputType=Shared 170 | 171 | [License] 172 | LicenseType=Project 173 | Product=Oxygene 174 | Platform=Island 175 | AllowBeta=1 176 | AllowFull=1 177 | 178 | DisplayName=SwiftBaseLibrary Contributor License, Oxygene/Island 179 | ProjectName=Swift.Shared 180 | ProjectFileName=Swift.Shared.elements 181 | ProjectGuid=7952073b-795c-4074-954d-212fe780d7d3 182 | ProjectAssemblyName=Swift.Shared 183 | ProjectOutputType=Shared 184 | 185 | [License] 186 | LicenseType=Project 187 | Product=Oxygene 188 | Platform=Toffee 189 | AllowBeta=1 190 | AllowFull=1 191 | 192 | DisplayName=SwiftBaseLibrary Contributor License, Oxygene/Toffee 193 | ProjectName=Swift.Shared 194 | ProjectFileName=Swift.Shared.elements 195 | ProjectGuid=7952073b-795c-4074-954d-212fe780d7d3 196 | ProjectAssemblyName=Swift.Shared 197 | ProjectOutputType=Shared 198 | 199 | [License] 200 | LicenseType=Project 201 | Product=Silver 202 | Platform=Cooper 203 | AllowBeta=1 204 | AllowFull=1 205 | 206 | DisplayName=SwiftBaseLibrary Contributor License, Silver/Cooper 207 | ProjectName=Swift.Shared 208 | ProjectFileName=Swift.Shared.elements 209 | ProjectGuid=7952073b-795c-4074-954d-212fe780d7d3 210 | ProjectAssemblyName=Swift.Shared 211 | ProjectOutputType=Shared 212 | 213 | [License] 214 | LicenseType=Project 215 | Product=Silver 216 | Platform=Echoes 217 | AllowBeta=1 218 | AllowFull=1 219 | 220 | DisplayName=SwiftBaseLibrary Contributor License, Silver/Echoes 221 | ProjectName=Swift.Shared 222 | ProjectFileName=Swift.Shared.elements 223 | ProjectGuid=7952073b-795c-4074-954d-212fe780d7d3 224 | ProjectAssemblyName=Swift.Shared 225 | ProjectOutputType=Shared 226 | 227 | [License] 228 | LicenseType=Project 229 | Product=Silver 230 | Platform=Island 231 | AllowBeta=1 232 | AllowFull=1 233 | 234 | DisplayName=SwiftBaseLibrary Contributor License, Silver/Island 235 | ProjectName=Swift.Shared 236 | ProjectFileName=Swift.Shared.elements 237 | ProjectGuid=7952073b-795c-4074-954d-212fe780d7d3 238 | ProjectAssemblyName=Swift.Shared 239 | ProjectOutputType=Shared 240 | 241 | [License] 242 | LicenseType=Project 243 | Product=Silver 244 | Platform=Toffee 245 | AllowBeta=1 246 | AllowFull=1 247 | 248 | DisplayName=SwiftBaseLibrary Contributor License, Silver/Toffee 249 | ProjectName=Swift.Shared 250 | ProjectFileName=Swift.Shared.elements 251 | ProjectGuid=7952073b-795c-4074-954d-212fe780d7d3 252 | ProjectAssemblyName=Swift.Shared 253 | ProjectOutputType=Shared 254 | 255 | [License] 256 | LicenseType=Project 257 | Product=Oxygene 258 | Platform=Toffee 259 | AllowBeta=1 260 | AllowFull=1 261 | 262 | DisplayName=SwiftBaseLibrary Contributor License, Oxygene/Toffee 263 | ProjectName=Swift.Toffee.iOS 264 | ProjectFileName=Swift.Toffee.iOS.elements 265 | ProjectGuid=95f9545c-39be-4a02-8673-8382ecb3f7ad 266 | ProjectAssemblyName=Swift 267 | ProjectOutputType=StaticLibrary 268 | 269 | [License] 270 | LicenseType=Project 271 | Product=Silver 272 | Platform=Toffee 273 | AllowBeta=1 274 | AllowFull=1 275 | 276 | DisplayName=SwiftBaseLibrary Contributor License, Silver/Toffee 277 | ProjectName=Swift.Toffee.iOS 278 | ProjectFileName=Swift.Toffee.iOS.elements 279 | ProjectGuid=95f9545c-39be-4a02-8673-8382ecb3f7ad 280 | ProjectAssemblyName=Swift 281 | ProjectOutputType=StaticLibrary 282 | 283 | [License] 284 | LicenseType=Project 285 | Product=Oxygene 286 | Platform=Toffee 287 | AllowBeta=1 288 | AllowFull=1 289 | 290 | DisplayName=SwiftBaseLibrary Contributor License, Oxygene/Toffee 291 | ProjectName=Swift.Toffee.macOS 292 | ProjectFileName=Swift.Toffee.macOS.elements 293 | ProjectGuid=8f87ccef-c142-49a8-8828-32211b2cbfbe 294 | ProjectAssemblyName=Swift 295 | ProjectOutputType=StaticLibrary 296 | 297 | [License] 298 | LicenseType=Project 299 | Product=Silver 300 | Platform=Toffee 301 | AllowBeta=1 302 | AllowFull=1 303 | 304 | DisplayName=SwiftBaseLibrary Contributor License, Silver/Toffee 305 | ProjectName=Swift.Toffee.macOS 306 | ProjectFileName=Swift.Toffee.macOS.elements 307 | ProjectGuid=8f87ccef-c142-49a8-8828-32211b2cbfbe 308 | ProjectAssemblyName=Swift 309 | ProjectOutputType=StaticLibrary 310 | 311 | [License] 312 | LicenseType=Project 313 | Product=Oxygene 314 | Platform=Toffee 315 | AllowBeta=1 316 | AllowFull=1 317 | 318 | DisplayName=SwiftBaseLibrary Contributor License, Oxygene/Toffee 319 | ProjectName=Swift.Toffee.tvOS 320 | ProjectFileName=Swift.Toffee.tvOS.elements 321 | ProjectGuid=ea152c1c-c6dd-48f8-9415-8b7fda4653d9 322 | ProjectAssemblyName=Swift 323 | ProjectOutputType=StaticLibrary 324 | 325 | [License] 326 | LicenseType=Project 327 | Product=Silver 328 | Platform=Toffee 329 | AllowBeta=1 330 | AllowFull=1 331 | 332 | DisplayName=SwiftBaseLibrary Contributor License, Silver/Toffee 333 | ProjectName=Swift.Toffee.tvOS 334 | ProjectFileName=Swift.Toffee.tvOS.elements 335 | ProjectGuid=ea152c1c-c6dd-48f8-9415-8b7fda4653d9 336 | ProjectAssemblyName=Swift 337 | ProjectOutputType=StaticLibrary 338 | 339 | [License] 340 | LicenseType=Project 341 | Product=Oxygene 342 | Platform=Toffee 343 | AllowBeta=1 344 | AllowFull=1 345 | 346 | DisplayName=SwiftBaseLibrary Contributor License, Oxygene/Toffee 347 | ProjectName=Swift.Toffee.watchOS 348 | ProjectFileName=Swift.Toffee.watchOS.elements 349 | ProjectGuid=e0c9dddb-b83f-4164-ade4-577fb6611f3f 350 | ProjectAssemblyName=Swift 351 | ProjectOutputType=StaticLibrary 352 | 353 | [License] 354 | LicenseType=Project 355 | Product=Silver 356 | Platform=Toffee 357 | AllowBeta=1 358 | AllowFull=1 359 | 360 | DisplayName=SwiftBaseLibrary Contributor License, Silver/Toffee 361 | ProjectName=Swift.Toffee.watchOS 362 | ProjectFileName=Swift.Toffee.watchOS.elements 363 | ProjectGuid=e0c9dddb-b83f-4164-ade4-577fb6611f3f 364 | ProjectAssemblyName=Swift 365 | ProjectOutputType=StaticLibrary 366 | 367 | 368 | [SignatureInfo] 369 | LicenseFileStartDate=2017-06-06 370 | LicenseFileEndDate=2018-06-08 371 | P1=4432753665844159297 372 | P2=6738596676932312466 373 | P3=3770065148 374 | P4=413100867 375 | 376 | -------------------------------------------------------------------------------- /Source/SwiftBaseLibrary.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # RemObjects Fire 4 | Project("{656346D9-4656-40DA-A068-22D5425D4639}") = "Swift.Cooper", "Swift.Cooper.elements", "{399BE68A-44C3-4357-8D11-4B64C6EC0674}" 5 | EndProject 6 | Project("{656346D9-4656-40DA-A068-22D5425D4639}") = "Swift.Echoes", "Swift.Echoes.elements", "{BAE82ECC-39A5-4A18-9CE1-EAC0653F6E0F}" 7 | EndProject 8 | Project("{656346D9-4656-40DA-A068-22D5425D4639}") = "Swift.Echoes.Standard", "Swift.Echoes.Standard.elements", "{CDDEBE6E-6B6B-4EF7-B2E1-57239C443426}" 9 | EndProject 10 | Project("{656346D9-4656-40DA-A068-22D5425D4639}") = "Swift.Island.Android", "Swift.Island.Android.elements", "{FA456B74-3E30-45ED-91B2-6BB7A104F836}" 11 | EndProject 12 | Project("{656346D9-4656-40DA-A068-22D5425D4639}") = "Swift.Island.Darwin.iOS", "Swift.Island.Darwin.iOS.elements", "{6F87C50F-069A-4E56-9B2E-044CBB68CC83}" 13 | EndProject 14 | Project("{656346D9-4656-40DA-A068-22D5425D4639}") = "Swift.Island.Darwin.macOS", "Swift.Island.Darwin.macOS.elements", "{792E19D0-3F6B-4EF5-A113-87C76EB0CE5E}" 15 | EndProject 16 | Project("{656346D9-4656-40DA-A068-22D5425D4639}") = "Swift.Island.Darwin.tvOS", "Swift.Island.Darwin.tvOS.elements", "{A037C663-4495-4630-A9EF-39079BA1EC07}" 17 | EndProject 18 | Project("{656346D9-4656-40DA-A068-22D5425D4639}") = "Swift.Island.Darwin.watchOS", "Swift.Island.Darwin.watchOS.elements", "{B9065575-47D6-4740-8D96-D8F5A1A30B0B}" 19 | EndProject 20 | Project("{656346D9-4656-40DA-A068-22D5425D4639}") = "Swift.Island.Linux", "Swift.Island.Linux.elements", "{A764B9EF-BE23-43AE-ACEB-43F24F45EAE9}" 21 | EndProject 22 | Project("{656346D9-4656-40DA-A068-22D5425D4639}") = "Swift.Island.WebAssembly", "Swift.Island.WebAssembly.elements", "{D38B4354-35C8-4BC9-9415-4D72A1F77CA1}" 23 | EndProject 24 | Project("{656346D9-4656-40DA-A068-22D5425D4639}") = "Swift.Island.Windows", "Swift.Island.Windows.elements", "{D32E206A-1255-4DA9-8287-64E5E988ABA4}" 25 | EndProject 26 | Project("{656346D9-4656-40DA-A068-22D5425D4639}") = "Swift.Shared", "Swift.Shared.elements", "{7952073B-795C-4074-954D-212FE780D7D3}" 27 | EndProject 28 | Project("{656346D9-4656-40DA-A068-22D5425D4639}") = "Swift.Tests", "..\Tests\Swift.Tests.elements", "{F22ABF38-8775-4118-8590-30756523030D}" 29 | EndProject 30 | Project("{656346D9-4656-40DA-A068-22D5425D4639}") = "Swift.Toffee.iOS", "Swift.Toffee.iOS.elements", "{95F9545C-39BE-4A02-8673-8382ECB3F7AD}" 31 | EndProject 32 | Project("{656346D9-4656-40DA-A068-22D5425D4639}") = "Swift.Toffee.macOS", "Swift.Toffee.macOS.elements", "{8F87CCEF-C142-49A8-8828-32211B2CBFBE}" 33 | EndProject 34 | Project("{656346D9-4656-40DA-A068-22D5425D4639}") = "Swift.Toffee.tvOS", "Swift.Toffee.tvOS.elements", "{EA152C1C-C6DD-48F8-9415-8B7FDA4653D9}" 35 | EndProject 36 | Project("{656346D9-4656-40DA-A068-22D5425D4639}") = "Swift.Toffee.watchOS", "Swift.Toffee.watchOS.elements", "{E0C9DDDB-B83F-4164-ADE4-577FB6611F3F}" 37 | EndProject 38 | Global 39 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 40 | Debug|AnyCPU = Debug|AnyCPU 41 | Release|AnyCPU = Release|AnyCPU 42 | EndGlobalSection 43 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 44 | {399BE68A-44C3-4357-8D11-4B64C6EC0674}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU 45 | {399BE68A-44C3-4357-8D11-4B64C6EC0674}.Debug|AnyCPU.Build.0 = Debug|AnyCPU 46 | {399BE68A-44C3-4357-8D11-4B64C6EC0674}.Release|AnyCPU.ActiveCfg = Release|AnyCPU 47 | {399BE68A-44C3-4357-8D11-4B64C6EC0674}.Release|AnyCPU.Build.0 = Release|AnyCPU 48 | {BAE82ECC-39A5-4A18-9CE1-EAC0653F6E0F}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU 49 | {BAE82ECC-39A5-4A18-9CE1-EAC0653F6E0F}.Debug|AnyCPU.Build.0 = Debug|AnyCPU 50 | {BAE82ECC-39A5-4A18-9CE1-EAC0653F6E0F}.Release|AnyCPU.ActiveCfg = Release|AnyCPU 51 | {BAE82ECC-39A5-4A18-9CE1-EAC0653F6E0F}.Release|AnyCPU.Build.0 = Release|AnyCPU 52 | {CDDEBE6E-6B6B-4EF7-B2E1-57239C443426}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU 53 | {CDDEBE6E-6B6B-4EF7-B2E1-57239C443426}.Debug|AnyCPU.Build.0 = Debug|AnyCPU 54 | {CDDEBE6E-6B6B-4EF7-B2E1-57239C443426}.Release|AnyCPU.ActiveCfg = Release|AnyCPU 55 | {CDDEBE6E-6B6B-4EF7-B2E1-57239C443426}.Release|AnyCPU.Build.0 = Release|AnyCPU 56 | {FA456B74-3E30-45ED-91B2-6BB7A104F836}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU 57 | {FA456B74-3E30-45ED-91B2-6BB7A104F836}.Debug|AnyCPU.Build.0 = Debug|AnyCPU 58 | {FA456B74-3E30-45ED-91B2-6BB7A104F836}.Release|AnyCPU.ActiveCfg = Release|AnyCPU 59 | {FA456B74-3E30-45ED-91B2-6BB7A104F836}.Release|AnyCPU.Build.0 = Release|AnyCPU 60 | {6F87C50F-069A-4E56-9B2E-044CBB68CC83}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU 61 | {6F87C50F-069A-4E56-9B2E-044CBB68CC83}.Debug|AnyCPU.Build.0 = Debug|AnyCPU 62 | {6F87C50F-069A-4E56-9B2E-044CBB68CC83}.Release|AnyCPU.ActiveCfg = Release|AnyCPU 63 | {6F87C50F-069A-4E56-9B2E-044CBB68CC83}.Release|AnyCPU.Build.0 = Release|AnyCPU 64 | {792E19D0-3F6B-4EF5-A113-87C76EB0CE5E}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU 65 | {792E19D0-3F6B-4EF5-A113-87C76EB0CE5E}.Debug|AnyCPU.Build.0 = Debug|AnyCPU 66 | {792E19D0-3F6B-4EF5-A113-87C76EB0CE5E}.Release|AnyCPU.ActiveCfg = Release|AnyCPU 67 | {792E19D0-3F6B-4EF5-A113-87C76EB0CE5E}.Release|AnyCPU.Build.0 = Release|AnyCPU 68 | {A037C663-4495-4630-A9EF-39079BA1EC07}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU 69 | {A037C663-4495-4630-A9EF-39079BA1EC07}.Debug|AnyCPU.Build.0 = Debug|AnyCPU 70 | {A037C663-4495-4630-A9EF-39079BA1EC07}.Release|AnyCPU.ActiveCfg = Release|AnyCPU 71 | {A037C663-4495-4630-A9EF-39079BA1EC07}.Release|AnyCPU.Build.0 = Release|AnyCPU 72 | {B9065575-47D6-4740-8D96-D8F5A1A30B0B}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU 73 | {B9065575-47D6-4740-8D96-D8F5A1A30B0B}.Debug|AnyCPU.Build.0 = Debug|AnyCPU 74 | {B9065575-47D6-4740-8D96-D8F5A1A30B0B}.Release|AnyCPU.ActiveCfg = Release|AnyCPU 75 | {B9065575-47D6-4740-8D96-D8F5A1A30B0B}.Release|AnyCPU.Build.0 = Release|AnyCPU 76 | {A764B9EF-BE23-43AE-ACEB-43F24F45EAE9}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU 77 | {A764B9EF-BE23-43AE-ACEB-43F24F45EAE9}.Debug|AnyCPU.Build.0 = Debug|AnyCPU 78 | {A764B9EF-BE23-43AE-ACEB-43F24F45EAE9}.Release|AnyCPU.ActiveCfg = Release|AnyCPU 79 | {A764B9EF-BE23-43AE-ACEB-43F24F45EAE9}.Release|AnyCPU.Build.0 = Release|AnyCPU 80 | {D38B4354-35C8-4BC9-9415-4D72A1F77CA1}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU 81 | {D38B4354-35C8-4BC9-9415-4D72A1F77CA1}.Debug|AnyCPU.Build.0 = Debug|AnyCPU 82 | {D38B4354-35C8-4BC9-9415-4D72A1F77CA1}.Release|AnyCPU.ActiveCfg = Release|AnyCPU 83 | {D38B4354-35C8-4BC9-9415-4D72A1F77CA1}.Release|AnyCPU.Build.0 = Release|AnyCPU 84 | {D32E206A-1255-4DA9-8287-64E5E988ABA4}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU 85 | {D32E206A-1255-4DA9-8287-64E5E988ABA4}.Debug|AnyCPU.Build.0 = Debug|AnyCPU 86 | {D32E206A-1255-4DA9-8287-64E5E988ABA4}.Release|AnyCPU.ActiveCfg = Release|AnyCPU 87 | {D32E206A-1255-4DA9-8287-64E5E988ABA4}.Release|AnyCPU.Build.0 = Release|AnyCPU 88 | {F22ABF38-8775-4118-8590-30756523030D}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU 89 | {F22ABF38-8775-4118-8590-30756523030D}.Debug|AnyCPU.Build.0 = Debug|AnyCPU 90 | {F22ABF38-8775-4118-8590-30756523030D}.Release|AnyCPU.ActiveCfg = Release|AnyCPU 91 | {F22ABF38-8775-4118-8590-30756523030D}.Release|AnyCPU.Build.0 = Release|AnyCPU 92 | {95F9545C-39BE-4A02-8673-8382ECB3F7AD}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU 93 | {95F9545C-39BE-4A02-8673-8382ECB3F7AD}.Debug|AnyCPU.Build.0 = Debug|AnyCPU 94 | {95F9545C-39BE-4A02-8673-8382ECB3F7AD}.Release|AnyCPU.ActiveCfg = Release|AnyCPU 95 | {95F9545C-39BE-4A02-8673-8382ECB3F7AD}.Release|AnyCPU.Build.0 = Release|AnyCPU 96 | {8F87CCEF-C142-49A8-8828-32211B2CBFBE}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU 97 | {8F87CCEF-C142-49A8-8828-32211B2CBFBE}.Debug|AnyCPU.Build.0 = Debug|AnyCPU 98 | {8F87CCEF-C142-49A8-8828-32211B2CBFBE}.Release|AnyCPU.ActiveCfg = Release|AnyCPU 99 | {8F87CCEF-C142-49A8-8828-32211B2CBFBE}.Release|AnyCPU.Build.0 = Release|AnyCPU 100 | {EA152C1C-C6DD-48F8-9415-8B7FDA4653D9}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU 101 | {EA152C1C-C6DD-48F8-9415-8B7FDA4653D9}.Debug|AnyCPU.Build.0 = Debug|AnyCPU 102 | {EA152C1C-C6DD-48F8-9415-8B7FDA4653D9}.Release|AnyCPU.ActiveCfg = Release|AnyCPU 103 | {EA152C1C-C6DD-48F8-9415-8B7FDA4653D9}.Release|AnyCPU.Build.0 = Release|AnyCPU 104 | {E0C9DDDB-B83F-4164-ADE4-577FB6611F3F}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU 105 | {E0C9DDDB-B83F-4164-ADE4-577FB6611F3F}.Debug|AnyCPU.Build.0 = Debug|AnyCPU 106 | {E0C9DDDB-B83F-4164-ADE4-577FB6611F3F}.Release|AnyCPU.ActiveCfg = Release|AnyCPU 107 | {E0C9DDDB-B83F-4164-ADE4-577FB6611F3F}.Release|AnyCPU.Build.0 = Release|AnyCPU 108 | EndGlobalSection 109 | GlobalSection(SolutionProperties) = preSolution 110 | HideSolutionNode = FALSE 111 | EndGlobalSection 112 | EndGlobal -------------------------------------------------------------------------------- /Source/UnicodeScalar_Extensions.swift: -------------------------------------------------------------------------------- 1 |  2 | 3 | public extension UnicodeScalar : Streamable { 4 | 5 | public var value: UInt32 { 6 | return self as! UInt32 7 | } 8 | 9 | public func escape(# asASCII: Bool) -> String { 10 | if asASCII && !isASCII() { 11 | #if JAVA 12 | return self.toString() 13 | #elseif CLR || ISLAND 14 | return self.ToString() 15 | #elseif COCOA 16 | return self.description() 17 | #endif 18 | } 19 | else { 20 | #if JAVA 21 | return NativeString.format("\\u{%8x}", self as! Int32) 22 | #elseif CLR || ISLAND 23 | return NativeString.Format("\\u{{{0:X8}}}", self as! Int32) 24 | #elseif COCOA 25 | return NativeString.stringWithFormat("\\u{%8x}", self as! Int32) 26 | #endif 27 | } 28 | } 29 | 30 | public func isASCII() -> Bool { 31 | return self <= 127 32 | } 33 | 34 | public func asString() -> String { 35 | let bytes: Byte[] = [self & 0xff, (self >> 8) & 0xff, (self >> 16) & 0xff, (self >> 24) & 0xff]//, 0, 0, 0, 0] 36 | #if JAVA 37 | return NativeString(bytes,"UTF16") 38 | #elseif CLR 39 | return System.Text.UTF32Encoding(/*bigendian:*/false, /*BOM:*/false).GetString(bytes, 0, 1) // todo check order 40 | #elseif ISLAND 41 | return Encoding.UTF32LE.GetString(bytes) 42 | #elseif COCOA 43 | return NativeString(bytes: bytes as! UnsafePointer, length: 4, encoding:.UTF32LittleEndianStringEncoding) 44 | #endif 45 | } 46 | 47 | public func writeTo(_ target: OutputStreamType) { 48 | //target.write(asString()) 49 | } 50 | 51 | #if JAVA 52 | //workaround for 75341: Silver: Cooper: adding any interface to a struct via extension requires implementing `equals` and `hashCode`. 53 | func equals(_ arg1: Object!) -> Boolean { 54 | if let v = arg1 as? UnicodeScalar { 55 | return v == self 56 | } 57 | return false 58 | } 59 | 60 | func hashCode() -> Integer { 61 | return value 62 | } 63 | #endif 64 | } -------------------------------------------------------------------------------- /Source/Unmanaged.swift: -------------------------------------------------------------------------------- 1 | #if DARWIN 2 | public struct Unmanaged where Instance : AnyObject { 3 | 4 | #if ISLAND 5 | func autorelease() -> Unmanaged { 6 | CFAutorelease(opaque) 7 | return self 8 | } 9 | func release() { 10 | CFRelease(opaque) 11 | } 12 | func retain() -> Unmanaged { 13 | CFRetain(opaque) 14 | return self 15 | } 16 | #endif 17 | 18 | func takeRetainedValue() -> Instance { 19 | return bridge(opaque, BridgeMode.Bridge) 20 | } 21 | 22 | func takeUnretainedValue() -> Instance { 23 | return bridge(opaque, BridgeMode.Transfer) 24 | } 25 | 26 | func toOpaque() -> OpaquePointer { 27 | return opaque 28 | } 29 | 30 | static func fromOpaque(_ value: OpaquePointer) -> Unmanaged { 31 | Unmanaged(with: value) 32 | } 33 | static func passRetained(_ value: Instance) -> Unmanaged { 34 | Unmanaged(retained: value) 35 | } 36 | static func passUnretained(_ value: Instance) -> Unmanaged { 37 | Unmanaged(unretained: value) 38 | } 39 | 40 | private let opaque: OpaquePointer 41 | 42 | private init(with value: OpaquePointer) { 43 | opaque = value 44 | } 45 | 46 | private init(withRetained value: Instance) { 47 | opaque = bridge(value, BridgeMode.Retained) 48 | } 49 | 50 | private init(withUnretained value: Instance) { 51 | opaque = bridge(value, BridgeMode.Bridge) 52 | } 53 | } 54 | #endif -------------------------------------------------------------------------------- /Source/__AssemblyInfo.swift: -------------------------------------------------------------------------------- 1 | import System.Reflection 2 | import System.Runtime.CompilerServices 3 | import System.Runtime.InteropServices 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | @assembly:AssemblyTitle("RemObjects Silver Base Library for Swift") 9 | @assembly:AssemblyDescription("") 10 | @assembly:AssemblyConfiguration("") 11 | @assembly:AssemblyCompany("RemObjects Software") 12 | @assembly:AssemblyProduct("RemObjects Elements") 13 | @assembly:AssemblyCopyright("Copyright © RemObjects Software 2014-") 14 | @assembly:AssemblyTrademark("") 15 | @assembly:AssemblyCulture("") 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | @assembly:ComVisible(false) 21 | 22 | // Version information for an assembly consists of the following four values: 23 | // 24 | // Major Version 25 | // Minor Version 26 | // Build Number 27 | // Revision 28 | // 29 | // You can specify all the values or you can default the Build and Revision Numbers 30 | // by import the ""*"" as shown below: 31 | // @assembly:AssemblyVersion("1.0.*") 32 | @assembly:AssemblyVersion("1.0.0.0") 33 | @assembly:AssemblyFileVersion("1.0.0.0") 34 | 35 | #if SIGN 36 | @assembly:AssemblyKeyName("RemObjectsSoftware") 37 | #endif -------------------------------------------------------------------------------- /Source/__Internal.swift: -------------------------------------------------------------------------------- 1 |  2 | func __newLine() -> NativeString { 3 | #if JAVA 4 | return System.getProperty("line.separator") 5 | #elseif CLR 6 | return System.Environment.NewLine 7 | #elseif ISLAND 8 | return RemObjects.Elements.System.Environment.NewLine 9 | #elseif COCOA 10 | return "\n" 11 | #endif 12 | } 13 | 14 | @inline(__always) func __toString(_ object: Object?) -> NativeString { 15 | if let object = object { 16 | #if JAVA 17 | return object.toString() 18 | #elseif CLR || ISLAND 19 | return object.ToString() 20 | #elseif COCOA 21 | return object.description 22 | #endif 23 | } else { 24 | return "(null)" 25 | } 26 | } 27 | 28 | @inline(__always) func __toNativeString(_ object: Object?) -> NativeString { 29 | if let object = object { 30 | #if JAVA 31 | return object.toString() 32 | #elseif CLR || ISLAND 33 | return object.ToString() 34 | #elseif COCOA 35 | return object.description 36 | #endif 37 | } else { 38 | return "(null)" 39 | } 40 | } -------------------------------------------------------------------------------- /Tests/Dictionary.swift: -------------------------------------------------------------------------------- 1 | import RemObjects.Elements.EUnit 2 | 3 | public class DictionaryTests : Test { 4 | 5 | public func test82211() { 6 | 7 | var dict = [String: String]() 8 | dict["test"] = "someString" 9 | 10 | writeLn("dict[\"test\"] \(dict["test"])") 11 | 12 | Check.AreEqual(dict["test"], "someString") // good 13 | Check.IsNotNil(dict["test"]) // good 14 | Check.IsTrue(assigned(dict["test"])) // fails 15 | Check.IsTrue(dict["test"] != nil) // fails 16 | writeLn("dict[\"test\"] != nil \(dict["test"] != nil)") // False 17 | writeLn("dict[\"test\"] == nil \(dict["test"] == nil)") // True 18 | 19 | let hasValue: Bool = dict["test"] != nil 20 | writeLn("hasValue \(hasValue)") 21 | if !hasValue { 22 | throw Exception("dict[test] is not nil!") 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Tests/Program.swift: -------------------------------------------------------------------------------- 1 | import RemObjects.Elements.EUnit 2 | 3 | let lTests = Discovery.DiscoverTests() 4 | return Runner.RunTests(lTests, withListener: Runner.DefaultListener) == TestState.Succeeded ? 0 : 1 -------------------------------------------------------------------------------- /Tests/Range.swift: -------------------------------------------------------------------------------- 1 | import RemObjects.Elements.EUnit 2 | 3 | public extension Range { 4 | public var allValuesAsString: String { 5 | var result = "" 6 | for v in self { 7 | if result != "" { 8 | result += "," 9 | } 10 | result += v 11 | } 12 | return result 13 | } 14 | } 15 | 16 | 17 | public class RangeTests : Test { 18 | 19 | public func FirstTest() { 20 | 21 | var openRange = 1..<5 22 | Check.AreEqual(openRange.description, "1..<5") 23 | Check.AreEqual(openRange.allValuesAsString, "1,2,3,4") 24 | 25 | var openRange2 = 5..<1 26 | Check.AreEqual(openRange2.description, "5..<1") 27 | Check.AreEqual(openRange2.allValuesAsString, "5,4,3,2") 28 | 29 | var reversedOpenRange = 5>..1 30 | Check.AreEqual(reversedOpenRange.description, "5>..1") 31 | Check.AreEqual(reversedOpenRange.allValuesAsString, "4,3,2,1") 32 | 33 | var reversedOpenRange2 = 1>..5 34 | Check.AreEqual(reversedOpenRange2.description, "1>..5") 35 | Check.AreEqual(reversedOpenRange2.allValuesAsString, "2,3,4,5") 36 | 37 | // 38 | // 39 | 40 | var closedRange = 1...5 41 | Check.AreEqual(closedRange.description, "1...5") 42 | Check.AreEqual(closedRange.allValuesAsString, "1,2,3,4,5") 43 | 44 | var reversedClosedRange = 5...1 45 | Check.AreEqual(reversedClosedRange.description, "5...1") 46 | Check.AreEqual(reversedClosedRange.allValuesAsString, "5,4,3,2,1") 47 | 48 | // 49 | // 50 | 51 | var looseOpenRange = ..<5 52 | Check.AreEqual(looseOpenRange.description, "..<5") 53 | Check.Throws() { _ = looseOpenRange.allValuesAsString } 54 | 55 | var looseOpenRange2 = 5>.. 56 | Check.AreEqual(looseOpenRange2.description, "5>..") 57 | //Check.Throws() { _ = looseOpenRange2.allValuesAsString } 58 | Check.AreEqual(looseOpenRange2.allValuesAsString, "4,3,2,1,0") 59 | 60 | // 61 | // 62 | 63 | var looseClosedRange = ...5 64 | Check.AreEqual(looseClosedRange.description, "...5") 65 | Check.Throws() { _ = looseClosedRange.allValuesAsString } 66 | 67 | var looseClosedRange2 = 5... 68 | Check.AreEqual(looseClosedRange2.description, "5...") 69 | //CANNOT TEST, infinmite sequence: // Check.Throws() { _ = looseClosedRange2.allValuesAsString } 70 | 71 | } 72 | 73 | } -------------------------------------------------------------------------------- /Tests/Swift.Tests.elements: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Swift 5 | {F22ABF38-8775-4118-8590-30756523030D} 6 | Executable 7 | Swift.Tests 8 | Release 9 | True 10 | Entitlements.entitlements 11 | True 12 | 13 | 14 | False 15 | .\Bin\Debug 16 | True 17 | DEBUG;TRACE; 18 | True 19 | 20 | 21 | .\Bin\Release 22 | 23 | 24 | Cooper 25 | Plain 26 | java.util,remobjects.elements.linq 27 | 28 | 29 | Echoes 30 | System.Collections.Generic;System.Linq 31 | 32 | 33 | Island 34 | Android 35 | 36 | 37 | Island 38 | Darwin 39 | macOS 40 | Foundation 41 | 42 | 43 | Island 44 | Darwin 45 | iOS 46 | Foundation 47 | 48 | 49 | Island 50 | Darwin 51 | tvOS 52 | Foundation 53 | 54 | 55 | Island 56 | Darwin 57 | watchOS 58 | Foundation 59 | 60 | 61 | Island 62 | Linux 63 | 64 | 65 | Island 66 | WebAssembly 67 | 68 | 69 | Island 70 | Windows 71 | 72 | 73 | 74 | Cooper 75 | 76 | 77 | True 78 | Cooper 79 | 80 | 81 | Cooper 82 | True 83 | 84 | 85 | Cooper 86 | True 87 | 88 | 89 | Echoes 90 | 91 | 92 | Echoes 93 | 94 | 95 | Echoes 96 | 97 | 98 | Echoes 99 | True 100 | 101 | 102 | Echoes 103 | True 104 | 105 | 106 | Echoes 107 | True 108 | 109 | 110 | Island.Darwin.macOS 111 | 112 | 113 | Island.Darwin.macOS 114 | 115 | 116 | Island.Darwin.macOS 117 | 118 | 119 | Island.Darwin.macOS 120 | 121 | 122 | Island.Darwin.macOS 123 | 124 | 125 | Island.Darwin.iOS 126 | 127 | 128 | Island.Darwin.iOS 129 | 130 | 131 | Island.Darwin.iOS 132 | 133 | 134 | Island.Darwin.iOS 135 | 136 | 137 | Island.Darwin.iOS 138 | 139 | 140 | Island.Darwin.tvOS 141 | 142 | 143 | Island.Darwin.tvOS 144 | 145 | 146 | Island.Darwin.tvOS 147 | 148 | 149 | Island.Darwin.tvOS 150 | 151 | 152 | Island.Darwin.tvOS 153 | 154 | 155 | Island.Darwin.watchOS 156 | 157 | 158 | Island.Darwin.watchOS 159 | 160 | 161 | Island.Darwin.watchOS 162 | 163 | 164 | Island.Darwin.watchOS 165 | 166 | 167 | Island.Darwin.watchOS 168 | 169 | 170 | Island.Windows 171 | 172 | 173 | Island.Windows 174 | 175 | 176 | Island.Windows 177 | 178 | 179 | Island.Windows 180 | 181 | 182 | Island.Linux 183 | 184 | 185 | Island.Linux 186 | 187 | 188 | Island.Linux 189 | 190 | 191 | Island.Linux 192 | 193 | 194 | Island.WebAssembly 195 | 196 | 197 | Island.WebAssembly 198 | 199 | 200 | Island.WebAssembly 201 | 202 | 203 | Island.Android 204 | 205 | 206 | Island.Android 207 | 208 | 209 | Island.Android 210 | 211 | 212 | Island.Android 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | -------------------------------------------------------------------------------- /Tests/Swift.Tests.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # RemObjects Fire 4 | Project("{656346D9-4656-40DA-A068-22D5425D4639}") = "Swift.Tests", "Swift.Tests.elements", "{F22ABF38-8775-4118-8590-30756523030D}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|AnyCPU = Debug|AnyCPU 9 | Release|AnyCPU = Release|AnyCPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {F22ABF38-8775-4118-8590-30756523030D}.Debug|AnyCPU.ActiveCfg = Debug|AnyCPU 13 | {F22ABF38-8775-4118-8590-30756523030D}.Debug|AnyCPU.Build.0 = Debug|AnyCPU 14 | {F22ABF38-8775-4118-8590-30756523030D}.Release|AnyCPU.ActiveCfg = Release|AnyCPU 15 | {F22ABF38-8775-4118-8590-30756523030D}.Release|AnyCPU.Build.0 = Release|AnyCPU 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal --------------------------------------------------------------------------------