猫·仁波切

会研发的PM才是好OP.

Swift and ObjectiveC Interop (Swift 与 Objective-C 之间的交互)

主要介绍原有 Objective-C 中的一些类型在 Swift 中的操作问题。差不多就能知道,你在 Swift 如何对 Objective-C (Foundation) 原生类型进行操作以及和 Swift 类型互转。

瞎写的,有错或者不明白的地方直接告诉我。转载注明我或者 SwiftChina 。

参考资料是 我的 Github : andelf/Defines-Swift 是我dump出的定义。10w行swift代码。

预备知识

Objective-C (Cocoa) 特色

数值类型统一用 NSNumber,不区分具体。大量操作在指针上进行,也就隐含着一切可能出错的调用都会返回 nil。 没有泛型支持,字典或者数组更多用 id 类型。

对应 Swift 特色

数值类型众多 (Int, UInt, Float, Double, ...),无指针(UnsafePointer 这类用于和其他代码交互的结构不计,& + inout 认为是引用。)。 nil 用于 Type?, Type!。字典和数组用泛型表示。

一些属性

有几个属性用于和 Objective-C 之间的交互。

@objc@objc(a_name_defined_in_objc)

@objc_block

用于函数类型前,标记后面的 block 是 Objective-C 的。个人觉得编译器会自动转换相关的 block 类型。

然后需要预备下几个属性的知识。

@conversion

Swift 中的隐式类型转换。有另一篇文章介绍。

@final

就是 final 了。

@transparent

经过反汇编查看,相当于 inline 的作用。同时生成的 .swiftmodule 文件依然带有原函数实现。这个很高大上。保证了 inline 特性在包外可用。

重要 Swift protocol

*LiteralConvertible

表示可以从 Swift 字面常量转换而得。比如 let a: Type = 100, 那么 Type 必须实现 IntegerLiteralConvertible。

大概有 IntegerLiteralConvertible, FloatLiteralConvertible, StringLiteralConvertible, ArrayLiteralConvertible, DictionaryLiteralConvertible, CharacterLiteralConvertible 等。

_BridgedToObjectiveC _ConditionallyBridgedToObjectiveC

顾名思义。就是相当于这个 Swift 类型可以和某一 Objective-C 类型对等,可以相互转换。

Conditional 多了个判断函数,也就是说这个类型可能是并没有对等起来的,什么情况下用呢,目前猜测应该是带泛型参数的类型中用到,有的泛型可以对应,有的不可以。

1
2
3
4
5
6
protocol _BridgedToObjectiveC {
  typealias ObjectiveCType
  class func getObjectiveCType() -> Any.Type
  func bridgeToObjectiveC() -> ObjectiveCType
  class func bridgeFromObjectiveC(source: ObjectiveCType) -> Self?
}

Reflectable Mirror

这个具体暂时不清楚。反射相关的两个 protocol 。

Sequence Generator

这两个用于 Swift 的 for-in 循环,简单说就是,实现了 Sequence 协议的对象可以 .generate() 出一个 Generator, 然后 Generator 可以不断地 .next() 返回 Type?,其中 Type 是这个序列的泛型。

Hashable Equatable

英汉字典拿来。所以其实为了让 Objective-C 类型在 Swift 代码中正常工作,这个是必不可少的。

第一部分,类型交互

For 类、方法、协议

通过 @objc(name) 转为 Swift 定义。其中 name 为 Objective-C 下的名字。

例如

1
2
3
4
5
6
7
8
9
10
@objc(NSNumber) class NSNumber : NSValue {
    @objc(init) convenience init()
    @objc var integerValue: Int {
        @objc(integerValue) get {}
    }
    ...
}
@objc(NSCopying) protocol NSCopying {
    @objc(copyWithZone:) func copyWithZone(zone: NSZone) -> AnyObject!
}

所有可能为 nil 的指针类型几乎都被转为 Type!,由于 ImplicitlyUnwrappedOptional 的特性,所以几乎用起来一样。

For 基础数字类型

Int, UInt, Float, Double 均实现了 _BridgedToObjectiveC, 其中类型参数 ObjectiveCType 均为 NSNumber

也就是说,可以直接 .getObjectiveCType() 获取到 NSNumber,然后剩下的就很熟悉了。

NSNumber 实现了 FloatLiteralConvertible, IntegerLiteralConvertible,所以其实,也可以直接从 Swift 字面常量获得。

For Bool

实际上 Objective-C 中的 BOOL 是某一数字类型,YES, NO 也分别是 1, 0 。

所以 Swift Bool 实现了 _BridgedToObjectiveC,对应于 NSNumber 类型。

For String

NSString 实现了 StringLiteralConvertible,可以直接通过字面常量获得,同时还有到 String 的隐式类型转换。

String 实现了 _BridgedToObjectiveC 对应于 NSString

1
2
3
extension NSString {
  @conversion func __conversion() -> String
}

这就是为什么官方文档说 Swift 中 String 和 Objective-C 基本是相同操作的。其实都是背后的隐式类型转换。

同时 Foundation 还为 String 扩充了很多方法,发现几个比较有意思的是 ._ns,直接返回 NSString, ._index(Int) 返回 String.Index,等等。

For Array

NSArray 实现了 ArrayLiteralConvertible, 可以从字面常量直接获得。还实现了到 AnyObject[] 的隐式类型转换。

Array<T> 实现了 _ConditionallyBridgedToObjectiveC, 对应于 NSArray.

NSArray 还实现了 Sequence 协议,也就是可以通过 for-in 操作。其中 generate() 返回 NSFastGenerator 类,这个应该是在原有 Foundation 没有的。 当然 .next() 返回 AnyObject?

For Dictionary

NSDictionary 实现了 DictionaryLiteralConvertible, Sequence。同时还实现了到 Dictionary<NSObject, AnyObject> 的隐式类型转换。

Dictionary<KeyType, ValueType> 实现了到 NSDictionary 的隐式类型转换。实现了 _ConditionallyBridgedToObjectiveC 对应于 NSDictionary

其他扩充类型

新类型 NSRange,实现了 _BridgedToObjectiveC,对应于 NSValue,实现了到 Range<Int> 的隐式类型转换。

NSMutableSet NSMutableDictionary NSSet NSMutableArray 均实现了 Sequence 可以 for-in .

第二部分:从 Swift 调用 Objective-C

一般说来,你在 Swift 项目新建 Objective-C 类的时候,直接弹出是否创建 Bridge Header 的窗口,点 YES 就是了,这时候一般多出来个 ProjectName-Bridging-Header.h

如果没有自动的话,这个配置在项目的 Build Settings 中的 Swift Compiler - Code Generation 子项里。

说到底,其实是调用编译命令的 -import-objc-header 参数,后面加上这个 Header 文件。

然后你就可以把你的 Objective-C Class 的 .h 文件都 import 到这个 Herder 文件里了。

所有 Swift 代码都可以直接调用。完全透明,自动生成。

第三部分:从 Objective-C 调用 Swift

头文件是 ProjectName-Swift.h。直接 import 。

不要吝啬你的键盘大量地加入 @objc 属性就是了。

具体实现据我猜测是这样,先 swift 调用 -emit-objc-header -emit-objc-header-path 参数控制生成 Objective-C 的 Header,同时 swift 编译为模块,然后再编译一次。

头文件内容大概是会包含一堆宏定义。然后是 Swift 的类定义等。这里可以看到 Swift 的 mangling 名字。

1
2
3
4
5
6
7
8
9
10
11
SWIFT_CLASS("_TtC5Hello11AppDelegate")
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (nonatomic) UIWindow * window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;
- (void)applicationWillResignActive:(UIApplication *)application;
- (void)applicationDidEnterBackground:(UIApplication *)application;
- (void)applicationWillEnterForeground:(UIApplication *)application;
- (void)applicationDidBecomeActive:(UIApplication *)application;
- (void)applicationWillTerminate:(UIApplication *)application;
- (instancetype)init OBJC_DESIGNATED_INITIALIZER;
@end

第四部分:一个 Swift 和 Objective-C 混合项目的编译过程

这里只先考虑一个 Swift 项目使用 Objective-C 代码的情况,这个应该暂时比较多见(使用旧的 MVC 代码,用新的 Swift 创建 ui 一类)。

  • 编译所有 X.swift 文件到 X.o (with -emit-objc-header, -import-objc-header) (其中包含 .swiftmodule 子过程)
    • 由于选项里有 -emit-objc-header,所以之后的 Objective-C 文件可以直接 import 对应的 ProjectName-Swift.h
  • 编译 X.mX.o
  • 链接所有 .o 生成可执行文件

Swift Any*

1
2
3
4
5
6
7
8
9
typealias Any = protocol<>

typealias AnyClass = AnyObject.Type

@class_protocol protocol AnyObject {
}

// Also there is another type:
Any.Type

Metatype Type

“The metatype of a class, structure, or enumeration type is the name of that type followed by .Type. The metatype of a protocol type—not the concrete type that conforms to the protocol at runtime—is the name of that protocol followed by .Protocol. For example, the metatype of the class type SomeClass is SomeClass.Type and the metatype of the protocol SomeProtocol is SomeProtocol.Protocol.”

摘录来自: Apple Inc. “The Swift Programming Language”。 iBooks. https://itun.es/cn/jEUH0.l

“You can use the postfix self expression to access a type as a value. For example, SomeClass.self returns SomeClass itself, not an instance of SomeClass. And SomeProtocol.self returns SomeProtocol itself, not an instance of a type that conforms to SomeProtocol at runtime. You can use a dynamicType expression with an instance of a type to access that instance’s runtime type as a value”

摘录来自: Apple Inc. “The Swift Programming Language”。 iBooks. https://itun.es/cn/jEUH0.l

Implicit Type Convertion in Swift (Swift 的隐式类型转换)

这是我自己给的命名,因为这个特性暂时看是 undocumented 的。通过 lldb 和 Xcode 的变量 inspector 功能发掘出来的。然后尝试调用没有问题。

This is an undocumented feature. I found it by lldb and the variable inspector of Xcode6-beta.

形式: @conversion func __conversion<T>() -> T { }

对了 Reddit 网友提出 @conversion 是可以省略的。个人认为编译器可能对不同的两种方式行为略有不同,最好还是加上。还有就是 @transparent 其实是表示 inline 。

先随便设想个场合。比如我们某个库需要表示一个二维点。

Suppose we need a Point type in our library.

1
2
3
4
5
struct Point {
    var x: Int = 0
    var y: Int = 0
}
let p = Point(x: 23, y: 45)

相信看了几天的 Swift,信手捏来啊。啧啧。 然后你发现你的另个库已经用了 (Int, Int) 来表示二维点了。。。。。你的把手头一堆的 Point 在转成 (Int, Int),或者加个什么方法。?

For some reason, we need to work with another library, which uses (Int, Int) as the representation of a point. Must we refacotr the code and add type conversion function calls?

妈蛋重构么?

No no~~

我们这样来

复习下 extension 语法, 加上这里要介绍的“隐式类型转换”

We can use the Swift’s hiding feature – Implicit Type Convertion(or to say Cast?).

1
2
3
4
5
extension Point {
    @conversion func __conversion() -> (Int, Int) {
        return (x, y)
    }
}

赞爆了。然后我们就可以这么写

The we can directly make a (Int, Int) from a Point.

1
2
3
let (x, y) = p
// suppose: func drawPoint(pt: (Int,Int)) { }
drawPoint(p)

你看无痛苦吧。然后所有需要 (Int, Int) 参数的函数,直接传递 Point 类型是没有任何问题的。(这个我也很吃惊,理论上这个玩意还是有个推导过程的,会有BUG什么的,没想到老crash 的 Swift 编译器竟然这个做得很好)

好吧这个例子实在是太渣了。我们换个例子说。

假设,我们有个库函数,接受 Color struct (r, g, b 三原色表示) 作为参数。 比如调用 setColor(Color(r:23, g:34, b:34)) 然后实际上颜色我们用字符串表示,比如"white", “black” 或者 UInt32 表示比如 #ffeeff 。。。

然后为了方便,我们本来需要写一些转换函数,然后调用。

现在不同了,比如我们给 String 写个 隐式转换,代码里直接用。(用protocol 也可以实现相同的功能)

1
2
3
4
5
6
7
8
9
10
11
12
13
extension String {
    @conversion func __conversion() -> Color {
        switch self {
        case "red":
            return Color(r:255, g:0, b: 0)
        case "green":
            return Color(r:0, g:255, b:0)
        .....
        default:
            return Color(r:0, g:0, b:0)
        }
    }
}

然后代码里用到 Color 的地方你直接写个 “red” 啊 “pink” 骚粉啊。都是没有问题的。 setColor(“red”)

上面都是废话。

隐式类型转换标准: @conversion func __conversion<T>() -> T { } 可以作为方法写到 struct 里。也可以通过 extension 附加。

以下内容再 Xcode6-beta3 中不适用 请参考 Swift 在 Xcode6-beta3 中的变化

然后就是语言本身中有个细小的问题 微博 onevcat 文章里提到。

nil 是 NilType 的唯一实例(来自Python的同学对这种定义一定不陌生) 而 Type? 是 Optional 类型的,是个enum,变种是 Some(T) 和 None.

1
2
3
4
enum Optional<T>  {
    case None
    case Some(T)
}

那同学你有没有想到 ,我们为什么可以给一个 Type? 赋值 nil 呢?

答案就是这里讲到的 隐式类型转换。

In Swift standard library, the unique nil has a type of NilType and is the only instance. And Type? is the shortcut to Option<T>, an enum.

Why we can directly set a Type? variable to nil?

The Implicit Types Convertion is the answer. The NilType implements conversion methed to Type? and Type!.

I’ve dump the definitions from lldb. You can find them in:

我导出的一些标准库定义在下面的链接。

My Github Repo

Swift Attributes

@availability(*, unavailable, message=“a Message”)

to disable a func?

@asmname(“a_name”)

Undocumented Attributes By me. :)

@asmname(“swift_xxxx”) func funname(…)

Builtin asm symbol. maybe internal functions.

这里用于调用 C 函数。相当于与 Objective-C 交互时候用的 @objc(name)。避免名字冲突,也可以相当于别名。

使用方法:

1
int println() { .... }
1
2
@asmname("println") func c_println() -> CInt; // 声明
c_println() // 调用

也就是 C 中的同名函数,我们可以给赋予一个别名,然后正常调用。

同时也用于指定 Swift 导出符号的名字,用于在 C 语言调用。

详细参考 简析Swift和C的交互

@transparent

用在函数、方法定义前,根据 lldb 和 llvm ir 猜测,作用相当于 inline。内联函数。

需要扯一点 Swift 的编译,会生成 .swiftmodule,这个文件里包含信息更多,引用外部 .swiftmodule 时候,inline 仍然有效。

@assignment

用于重载操作符时表示赋值副作用。参数类型需要标记为 inout。参考运算符重载的那篇文章。

Swift 运算符重载、自定义运算符

@final

这个好像没什么多说的。文档里有。类似 java 的 final,C井中的 sealed

@conversion

参考上面的一篇。隐式类型转换好了。

Implicit Type Convertion in Swift //Swift 的隐式类型转换

@noreturn

表示函数不返回它的调用者。类似于 Rust 的 Buttom Type。

实例:

1
@noreturn @transparent func fatalError(message: StaticString, file: StaticString = default, line: UWord = default)

执行后打印出错消息,退出。

@auto_closure

用于函数参数类型前,表示一个空参数的 closure,调用时直接以语句的方式创建 closure,很自然。

1
2
3
4
5
6
7
8
func simpleAssert(condition: @auto_closure () -> Bool, message: String) {
    if !condition() {
        println(message)
    }
}
let testNumber = 5
simpleAssert(testNumber % 2 == 0, "testNumber isn't an even number.")
// prints "testNumber isn't an even number.

simpleAssert 中第一个参数,实际上是自动创建了一个 closure。文档中有详细描述。

@IBAction, @IBDesignable, @IBInspectable, and @IBOutlet

同 Objective-C

@objc @objc(name:name:)

参考文档。

@objc_block

@class_protocol

@required

@optional

@UIApplicationMain

@NSManaged

@NSCopying

@lazy

In class property:

@lazy let prop_name: PropType = PropType()

@exported

e.g.

@exported import ModName

@sil_weak

@sil_unowned

@sil_unmanaged

猜测是语言内部表示一个属性禁用 ARC?

Safety Integrity Level

@sil_self

@opened(…)

@cc(…)

@autoreleased

@objc_metatype

@LLDBDebuggerFunction

@requires_stored_property_inits

1
2
@requires_stored_property_inits class Point {
  ...

only in sil modules

  • @callee_unowned
  • @callee_owned
  • @callee_guaranteed
  • @guaranteed
  • @out
  • @thin
  • @thick
  • @owned

unused

这里可以看到一些 Swift 的历史变迁。4 年也不算很短。

  • @lvalue
  • @unchecked
    • ‘@unchecked T?’ syntax is going away, use ’T!'
  • @inout
    • @inout is no longer an attribute 应该是现在的 inout 关键字
  • @unowned
    • ‘@unowned’ is not an attribute, use the ‘unowned’ keyword instead

Swift Standard Library Cont. (Swift 标准库 第二部分)

UPDATE: 我还真没用过 Xcode。 输入 import Swift,按住 Command 鼠标点击 Swift。然后就出来了。 ORZ。 via reddit。

不过那个列表是不全的,有部分影藏的还是要慢慢来。比如 NilType.

通过命令行 lldb 命令获得相关信息。转载注明。

所有默认名字在 Swift 名字空间,即 Swift.abs 这样。这里是第二部分,小写符号请参考,前一篇。

第二部分 A to Z

AbsoluteValuable

1
2
3
protocol AbsoluteValuable : SignedNumber {
  class func abs(_: Self) -> Self
}

Any

1
typealias Any = protocol<>

AnyClass

1
typealias AnyClass = AnyObject.Type

AnyObject

1
@objc @class_protocol protocol AnyObject {}

Array

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
struct Array<T> : MutableCollection, Sliceable {
  typealias Element = T
  var startIndex: Int {
    get {}
  }
  var endIndex: Int {
    get {}
  }
  subscript (index: Int) -> T {
    get {}
    set {}
  }
  func generate() -> IndexingGenerator<Array<T>>
  typealias SliceType = Slice<T>
  subscript (subRange: Range<Int>) -> Slice<T> {
    get {}
    set(rhs) {}
  }
  typealias _Buffer = ArrayBuffer<T>
  init(_ buffer: ArrayBuffer<T>)
  var _buffer: ArrayBuffer<T>
}
extension Array<T> : ArrayLiteralConvertible {
  static func convertFromArrayLiteral(elements: T...) -> Array<T>
}
extension Array<T> {
  func _asCocoaArray() -> _CocoaArray
}
extension Array<T> : ArrayType {
  init()
  init<S : Sequence where T == T>(_ s: S)
  init(count: Int, repeatedValue: T)
  var count: Int {
    get {}
  }
  var capacity: Int {
    get {}
  }
  var isEmpty: Bool {
    get {}
  }
  var _owner: AnyObject? {
    get {}
  }
  var _elementStorageIfContiguous: UnsafePointer<T> {
    get {}
  }
  func copy() -> Array<T>
  func unshare()
  func reserveCapacity(minimumCapacity: Int)
  func append(newElement: T)
  func extend<S : Sequence where T == T>(sequence: S)
  func removeLast() -> T
  func insert(newElement: T, atIndex: Int)
  func removeAtIndex(index: Int) -> T
  func removeAll(keepCapacity: Bool = default)
  func join<S : Sequence where Array<T> == Array<T>>(elements: S) -> Array<T>
  func reduce<U>(initial: U, combine: (U, T) -> U) -> U
  func sort(isOrderedBefore: (T, T) -> Bool)
  func map<U>(transform: (T) -> U) -> Array<U>
  func reverse() -> Array<T>
  func filter(includeElement: (T) -> Bool) -> Array<T>
}
extension Array<T> : Reflectable {
  func getMirror() -> Mirror
}
extension Array<T> : Printable, DebugPrintable {
  func _makeDescription(#isDebug: Bool) -> String
  var description: String {
    get {}
  }
  var debugDescription: String {
    get {}
  }
}
extension Array<T> {
  @transparent func _cPointerArgs() -> (AnyObject?, RawPointer)
  @conversion @transparent func __conversion() -> CConstPointer<T>
  @conversion @transparent func __conversion() -> CConstVoidPointer
}
extension Array<T> {
  func withUnsafePointerToElements<R>(body: (UnsafePointer<T>) -> R) -> R
}
extension Array<T> {
  static func convertFromHeapArray(base: RawPointer, owner: NativeObject, count: Word) -> Array<T>
}
extension Array<T> {
  func replaceRange<C : Collection where T == T>(subRange: Range<Int>, with newValues: C)
}

ArrayBound

1
2
3
4
protocol ArrayBound {
  typealias ArrayBoundType
  func getArrayBoundValue() -> ArrayBoundType
}

ArrayBuffer

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
struct ArrayBuffer<T> : ArrayBufferType {
  var storage: NativeObject?
  var indirect: IndirectArrayBuffer {
    get {}
  }
  typealias Element = T
  init()
  init(_ cocoa: _CocoaArray)
  init(_ buffer: IndirectArrayBuffer)
  func castToBufferOf<U>(_: U.Type) -> ArrayBuffer<U>
}
extension ArrayBuffer<T> {
  init(_ source: ContiguousArrayBuffer<T>)
  func isUniquelyReferenced() -> Bool
  func _asCocoaArray() -> _CocoaArray
  var _hasMutableBuffer: Bool {
    get {}
  }
  func requestUniqueMutableBuffer(minimumCapacity: Int) -> ContiguousArrayBuffer<T>?
  func requestNativeBuffer() -> ContiguousArrayBuffer<T>?
  func _typeCheck(subRange: Range<Int>)
  func _uninitializedCopy(subRange: Range<Int>, target: UnsafePointer<T>) -> UnsafePointer<T>
  subscript (subRange: Range<Int>) -> SliceBuffer<T> {
    get {}
  }
  var elementStorage: UnsafePointer<T> {
    get {}
  }
  var count: Int {
    get {}
    set {}
  }
  var capacity: Int {
    get {}
  }
  subscript (i: Int) -> T {
    get {}
    set {}
  }
  func withUnsafePointerToElements<R>(body: (UnsafePointer<T>) -> R) -> R
  var owner: AnyObject? {
    get {}
  }
  var identity: Word {
    get {}
  }
  var startIndex: Int {
    get {}
  }
  var endIndex: Int {
    get {}
  }
  func generate() -> IndexingGenerator<ArrayBuffer<T>>
  typealias Storage = ContiguousArrayStorage<T>
  typealias NativeBuffer = ContiguousArrayBuffer<T>
  func _invariantCheck() -> Bool
  var _isNative: Bool {
    get {}
  }
  var _native: ContiguousArrayBuffer<T> {
    get {}
  }
  var _nonNative: _CocoaArray? {
    get {}
  }
}

ArrayBufferType

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
protocol ArrayBufferType : MutableCollection {
  typealias Element
  init()
  init(_ buffer: ContiguousArrayBuffer<Element>)
  func _uninitializedCopy(subRange: Range<Int>, target: UnsafePointer<Element>) -> UnsafePointer<Element>
  func _asCocoaArray() -> _CocoaArray
  subscript (index: Int) -> Element { get set }
  func requestUniqueMutableBuffer(minimumCapacity: Int) -> ContiguousArrayBuffer<Element>?
  func requestNativeBuffer() -> ContiguousArrayBuffer<Element>?
  subscript (subRange: Range<Int>) -> SliceBuffer<Element> { get }
  func withUnsafePointerToElements<R>(body: (UnsafePointer<Element>) -> R) -> R
  var count: Int { get set }
  var capacity: Int { get }
  var owner: AnyObject? { get }
  var elementStorage: UnsafePointer<Element> { get }
  var identity: Word { get }
}

ArrayLiteralConvertible

1
2
3
4
protocol ArrayLiteralConvertible {
  typealias Element
  class func convertFromArrayLiteral(elements: Element...) -> Self
}

ArrayType

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
protocol ArrayType : _ArrayType, ExtensibleCollection, MutableSliceable, ArrayLiteralConvertible {
  init()
  init(count: Int, repeatedValue: Self.GeneratorType.Element)
  var count: Int { get }
  var capacity: Int { get }
  var isEmpty: Bool { get }
  var _owner: AnyObject? { get }
  var _elementStorageIfContiguous: UnsafePointer<Self.Element> { get }
  subscript (index: Int) -> Self.GeneratorType.Element { get set }
  func reserveCapacity(minimumCapacity: Int)
  func append(newElement: Self.GeneratorType.Element)
  func extend<S : Sequence where `Self`.GeneratorType.Element == Self.GeneratorType.Element>(sequence: S)
  func removeLast() -> Self.GeneratorType.Element
  func insert(newElement: Self.GeneratorType.Element, atIndex: Int)
  func removeAtIndex(index: Int) -> Self.GeneratorType.Element
  func removeAll(#keepCapacity: Bool)
  func join<S : Sequence where `Self` == Self>(elements: S) -> Self
  func reduce<U>(initial: U, combine: (U, Self.GeneratorType.Element) -> U) -> U
  func sort(isOrderedBefore: (Self.GeneratorType.Element, Self.GeneratorType.Element) -> Bool)
  typealias _Buffer : ArrayBufferType
  init(_ buffer: _Buffer)
  var _buffer: _Buffer { get set }
}
1
2
3
4
5
protocol _ArrayType : Collection {
  var count: Int { get }
  typealias _Buffer : ArrayBufferType
  var _buffer: _Buffer { get }
}

AutoreleasingUnsafePointer

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
struct AutoreleasingUnsafePointer<T> : Equatable, LogicValue {
  let value: RawPointer
  @transparent init(_ value: RawPointer)
  @transparent static func __writeback_conversion_get(x: T) -> RawPointer
  @transparent static func __writeback_conversion_set(x: RawPointer) -> T
  @transparent static func __writeback_conversion(inout autoreleasingTemp: RawPointer) -> AutoreleasingUnsafePointer<T>
  var _isNull: Bool {
    @transparent get {}
  }
  @transparent func getLogicValue() -> Bool
  var memory: T {
    @transparent get {}
    @transparent set {}
  }
}

BidirectionalIndex

1
protocol BidirectionalIndex : ForwardIndex, _BidirectionalIndex {}
1
2
3
protocol _BidirectionalIndex : _ForwardIndex {
  func pred() -> Self
}

Bit

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
enum Bit : Int, RandomAccessIndex {
  case zero
  case one
  func succ() -> Bit
  func pred() -> Bit
  func distanceTo(other: Bit) -> Int
  func advancedBy(distance: Int) -> Bit
  var hashValue: Int {
    get {}
  }
  static func fromRaw(raw: Int) -> Bit?
  func toRaw() -> Int
}
extension Bit : IntegerArithmetic {
  static func _withOverflow(x: Int, _ b: Bool) -> (Bit, Bool)
  static func uncheckedAdd(lhs: Bit, _ rhs: Bit) -> (Bit, Bool)
  static func uncheckedSubtract(lhs: Bit, _ rhs: Bit) -> (Bit, Bool)
  static func uncheckedMultiply(lhs: Bit, _ rhs: Bit) -> (Bit, Bool)
  static func uncheckedDivide(lhs: Bit, _ rhs: Bit) -> (Bit, Bool)
  static func uncheckedModulus(lhs: Bit, _ rhs: Bit) -> (Bit, Bool)
  func toIntMax() -> IntMax
}

BitwiseOperations

1
2
3
4
5
6
7
protocol BitwiseOperations {
  func &(_: Self, _: Self) -> Self
  func |(_: Self, _: Self) -> Self
  func ^(_: Self, _: Self) -> Self
  func ~(_: Self) -> Self
  class var allZeros: Self { get }
}

Bool

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
struct Bool {
  var value: Int1
  @transparent init()
  @transparent init(_ v: Int1)
  static var false: Bool {
    @transparent get {}
  }
  static var true: Bool {
    @transparent get {}
  }
}
extension Bool : LogicValue {
  @transparent func _getBuiltinLogicValue() -> Int1
  @transparent func getLogicValue() -> Bool
  init(_ v: LogicValue)
}
extension Bool : Printable {
  var description: String {
    get {}
  }
}
extension Bool : Equatable, Hashable {
  var hashValue: Int {
    @transparent get {}
  }
}
extension Bool : Reflectable {
  func getMirror() -> Mirror
}

CBool

1
typealias CBool = Bool

CChar

1
typealias CChar = Int8

CChar16

1
typealias CChar16 = UInt16

CChar32

1
typealias CChar32 = UnicodeScalar

CConstPointer

1
2
3
4
5
6
7
8
9
10
struct CConstPointer<T> : Equatable {
  let owner: AnyObject?
  let value: RawPointer
  @transparent init(_ owner: AnyObject?, _ value: RawPointer)
  @transparent static func __inout_conversion(inout scalar: T) -> CConstPointer<T>
  var scoped: Bool {
    @transparent get {}
  }
  @transparent func withUnsafePointer<U>(f: UnsafePointer<T> -> U) -> U
}

CConstVoidPointer

1
2
3
4
5
6
7
8
9
10
struct CConstVoidPointer : Equatable {
  let owner: AnyObject?
  let value: RawPointer
  @transparent init(_ owner: AnyObject?, _ value: RawPointer)
  @transparent static func __inout_conversion<T>(inout scalar: T) -> CConstVoidPointer
  var scoped: Bool {
    @transparent get {}
  }
  @transparent func withUnsafePointer<T, U>(f: UnsafePointer<T> -> U) -> U
}

CDouble

1
typealias CDouble = Double

CFloat

1
typealias CFloat = Float

Character

1
2
3
4
5
6
7
8
9
10
11
12
13
enum Character : _BuiltinExtendedGraphemeClusterLiteralConvertible, ExtendedGraphemeClusterLiteralConvertible, Equatable {
  case LargeRepresentation(OnHeap<String>)
  case SmallRepresentation(Int63)
  init(_ scalar: UnicodeScalar)
  static func _convertFromBuiltinExtendedGraphemeClusterLiteral(start: RawPointer, byteSize: Word, isASCII: Int1) -> Character
  static func convertFromExtendedGraphemeClusterLiteral(value: Character) -> Character
  init(_ s: String)
  static func _smallSize(value: UInt64) -> Int
  static func _smallValue(value: Int63) -> UInt64
}
extension Character : Streamable {
  func writeTo<Target : OutputStream>(inout target: Target)
}

CharacterLiteralConvertible

1
2
3
4
protocol CharacterLiteralConvertible {
  typealias CharacterLiteralType : _BuiltinCharacterLiteralConvertible
  class func convertFromCharacterLiteral(value: CharacterLiteralType) -> Self
}

CInt

1
typealias CInt = Int32

CLong

1
typealias CLong = Int

CLongLong

1
typealias CLongLong = Int64

CMutablePointer

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
struct CMutablePointer<T> : Equatable, LogicValue {
  let owner: AnyObject?
  let value: RawPointer
  @transparent static func __inout_conversion(inout scalar: T) -> CMutablePointer<T>
  @transparent static func __inout_conversion(inout a: Array<T>) -> CMutablePointer<T>
  var scoped: Bool {
    @transparent get {}
  }
  @transparent func withUnsafePointer<U>(f: UnsafePointer<T> -> U) -> U
  @transparent func getLogicValue() -> Bool
  @transparent func _withBridgeObject<U, R>(inout buffer: U?, body: (AutoreleasingUnsafePointer<U?>) -> R) -> R
  @transparent func _withBridgeValue<U, R>(inout buffer: U, body: (CMutablePointer<U>) -> R) -> R
  func _setIfNonNil(body: () -> T)
  init(owner: AnyObject?, value: RawPointer)
}

CMutableVoidPointer

1
2
3
4
5
6
7
8
9
10
11
struct CMutableVoidPointer : Equatable {
  let owner: AnyObject?
  let value: RawPointer
  @transparent static func __inout_conversion<T>(inout scalar: T) -> CMutableVoidPointer
  @transparent static func __inout_conversion<T>(inout a: Array<T>) -> CMutableVoidPointer
  var scoped: Bool {
    @transparent get {}
  }
  @transparent func withUnsafePointer<T, U>(f: UnsafePointer<T> -> U) -> U
  init(owner: AnyObject?, value: RawPointer)
}

Collection

1
2
3
4
protocol Collection : _Collection, Sequence {
  subscript (i: Self.IndexType) -> Self.GeneratorType.Element { get }
  func ~>(_: Self, _: (_CountElements, ())) -> Self.IndexType.DistanceType
}

CollectionOfOne

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
struct CollectionOfOne<T> : Collection {
  typealias IndexType = Bit
  init(_ element: T)
  var startIndex: IndexType {
    get {}
  }
  var endIndex: IndexType {
    get {}
  }
  func generate() -> GeneratorOfOne<T>
  subscript (i: IndexType) -> T {
    get {}
  }
  let element: T
}

Comparable

1
2
3
4
5
protocol Comparable : _Comparable, Equatable {
  func <=(lhs: Self, rhs: Self) -> Bool
  func >=(lhs: Self, rhs: Self) -> Bool
  func >(lhs: Self, rhs: Self) -> Bool
}
1
2
3
protocol _Comparable {
  func <(lhs: Self, rhs: Self) -> Bool
}

ContiguousArray

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
struct ContiguousArray<T> : MutableCollection, Sliceable {
  typealias Element = T
  var startIndex: Int {
    get {}
  }
  var endIndex: Int {
    get {}
  }
  subscript (index: Int) -> T {
    get {}
    set {}
  }
  func generate() -> IndexingGenerator<ContiguousArray<T>>
  typealias SliceType = Slice<T>
  subscript (subRange: Range<Int>) -> Slice<T> {
    get {}
    set(rhs) {}
  }
  typealias _Buffer = ContiguousArrayBuffer<T>
  init(_ buffer: ContiguousArrayBuffer<T>)
  var _buffer: ContiguousArrayBuffer<T>
}
extension ContiguousArray<T> : ArrayLiteralConvertible {
  static func convertFromArrayLiteral(elements: T...) -> ContiguousArray<T>
}
extension ContiguousArray<T> {
  func _asCocoaArray() -> _CocoaArray
}
extension ContiguousArray<T> : ArrayType {
  init()
  init<S : Sequence where T == T>(_ s: S)
  init(count: Int, repeatedValue: T)
  var count: Int {
    get {}
  }
  var capacity: Int {
    get {}
  }
  var isEmpty: Bool {
    get {}
  }
  var _owner: AnyObject? {
    get {}
  }
  var _elementStorageIfContiguous: UnsafePointer<T> {
    get {}
  }
  var _elementStorage: UnsafePointer<T> {
    get {}
  }
  func copy() -> ContiguousArray<T>
  func unshare()
  func reserveCapacity(minimumCapacity: Int)
  func append(newElement: T)
  func extend<S : Sequence where T == T>(sequence: S)
  func removeLast() -> T
  func insert(newElement: T, atIndex: Int)
  func removeAtIndex(index: Int) -> T
  func removeAll(keepCapacity: Bool = default)
  func join<S : Sequence where ContiguousArray<T> == ContiguousArray<T>>(elements: S) -> ContiguousArray<T>
  func reduce<U>(initial: U, combine: (U, T) -> U) -> U
  func sort(isOrderedBefore: (T, T) -> Bool)
  func map<U>(transform: (T) -> U) -> ContiguousArray<U>
  func reverse() -> ContiguousArray<T>
  func filter(includeElement: (T) -> Bool) -> ContiguousArray<T>
}
extension ContiguousArray<T> : Reflectable {
  func getMirror() -> Mirror
}
extension ContiguousArray<T> : Printable, DebugPrintable {
  func _makeDescription(#isDebug: Bool) -> String
  var description: String {
    get {}
  }
  var debugDescription: String {
    get {}
  }
}
extension ContiguousArray<T> {
  @transparent func _cPointerArgs() -> (AnyObject?, RawPointer)
  @conversion @transparent func __conversion() -> CConstPointer<T>
  @conversion @transparent func __conversion() -> CConstVoidPointer
}
extension ContiguousArray<T> {
  func withUnsafePointerToElements<R>(body: (UnsafePointer<T>) -> R) -> R
}
extension ContiguousArray<T> {
  func replaceRange<C : Collection where T == T>(subRange: Range<Int>, with newValues: C)
}

ContiguousArrayBuffer

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
struct ContiguousArrayBuffer<T> : ArrayBufferType, LogicValue {
  init(count: Int, minimumCapacity: Int)
  init(_ storage: ContiguousArrayStorage<T>?)
  func getLogicValue() -> Bool
  var elementStorage: UnsafePointer<T> {
    get {}
  }
  var _unsafeElementStorage: UnsafePointer<T> {
    get {}
  }
  func withUnsafePointerToElements<R>(body: (UnsafePointer<T>) -> R) -> R
  func take() -> ContiguousArrayBuffer<T>
  typealias Element = T
  init()
  init(_ buffer: ContiguousArrayBuffer<T>)
  func requestUniqueMutableBuffer(minimumCapacity: Int) -> ContiguousArrayBuffer<T>?
  func requestNativeBuffer() -> ContiguousArrayBuffer<T>?
  subscript (i: Int) -> T {
    get {}
    set {}
  }
  var count: Int {
    get {}
    set {}
  }
  var capacity: Int {
    get {}
  }
  func _uninitializedCopy(subRange: Range<Int>, target: UnsafePointer<T>) -> UnsafePointer<T>
  subscript (subRange: Range<Int>) -> SliceBuffer<T> {
    get {}
  }
  func isUniquelyReferenced() -> Bool
  func isMutable() -> Bool
  func _asCocoaArray() -> _CocoaArray
  var owner: AnyObject? {
    get {}
  }
  var identity: Word {
    get {}
  }
  func canStoreElementsOfDynamicType(proposedElementType: Any.Type) -> Bool
  func storesOnlyElementsOfType<U>(_: U.Type) -> Bool
  var _storage: ContiguousArrayStorage<T>? {
    get {}
  }
  typealias _Base = HeapBuffer<_ArrayBody, T>
  var _base: HeapBuffer<_ArrayBody, T>
}
extension ContiguousArrayBuffer<T> : Collection {
  var startIndex: Int {
    get {}
  }
  var endIndex: Int {
    get {}
  }
  func generate() -> IndexingGenerator<ContiguousArrayBuffer<T>>
}

ContiguousArrayStorage

1
2
3
4
5
6
7
8
9
10
@objc @final class ContiguousArrayStorage<T> : _NSSwiftArray {
  typealias Buffer = ContiguousArrayBuffer<T>
  @objc deinit
  @final @final @final @final func __getInstanceSizeAndAlignMask() -> (Int, Int)
  @final @final @final override func canStoreElementsOfDynamicType(proposedElementType: Any.Type) -> Bool
  @final @final @final override var staticElementType: Any.Type {
    @final @final @final get {}
  }
  init()
}

COpaquePointer

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
struct COpaquePointer : Equatable, Hashable, LogicValue {
  var value: RawPointer
  init()
  init(_ v: RawPointer)
  static func null() -> COpaquePointer
  var _isNull: Bool {
    @transparent get {}
  }
  @transparent func getLogicValue() -> Bool
  var hashValue: Int {
    get {}
  }
}
extension COpaquePointer {
  @conversion @transparent func __conversion() -> CMutableVoidPointer
  @conversion @transparent func __conversion() -> CConstVoidPointer
}
extension COpaquePointer {
  init<T>(_ from: UnsafePointer<T>)
}
extension COpaquePointer : CVarArg {
  func encode() -> Word[]
}

CShort

1
typealias CShort = Int16

CSignedChar

1
typealias CSignedChar = Int8

CString

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
struct CString : _BuiltinExtendedGraphemeClusterLiteralConvertible, ExtendedGraphemeClusterLiteralConvertible, _BuiltinStringLiteralConvertible, StringLiteralConvertible, LogicValue {
  var _bytesPtr: UnsafePointer<UInt8>
  @transparent init(_ _bytesPtr: UnsafePointer<UInt8>)
  static func _convertFromBuiltinExtendedGraphemeClusterLiteral(start: RawPointer, byteSize: Word, isASCII: Int1) -> CString
  static func convertFromExtendedGraphemeClusterLiteral(value: CString) -> CString
  static func _convertFromBuiltinStringLiteral(start: RawPointer, byteSize: Word, isASCII: Int1) -> CString
  static func convertFromStringLiteral(value: CString) -> CString
  var _isNull: Bool {
    @transparent get {}
  }
  @transparent func getLogicValue() -> Bool
  func persist() -> CChar[]?
}
extension CString : DebugPrintable {
  var debugDescription: String {
    get {}
  }
}
extension CString : Equatable, Hashable, Comparable {
  var hashValue: Int {
    get {}
  }
}
extension CString : Streamable {
  func writeTo<Target : OutputStream>(inout target: Target)
}

CUnsignedChar

1
typealias CUnsignedChar = UInt8

CUnsignedInt

1
typealias CUnsignedInt = UInt32

CUnsignedLong

1
typealias CUnsignedLong = UInt

CUnsignedLongLong

1
typealias CUnsignedLongLong = UInt64

CUnsignedShort

1
typealias CUnsignedShort = UInt16

CVaListPointer

1
2
3
4
5
struct CVaListPointer {
  var value: UnsafePointer<Void>
  init(fromUnsafePointer from: UnsafePointer<Void>)
  @conversion func __conversion() -> CMutableVoidPointer
}

CVarArg

1
2
3
protocol CVarArg {
  func encode() -> Word[]
}

CWideChar

1
typealias CWideChar = UnicodeScalar

DebugPrintable

1
2
3
protocol DebugPrintable {
  var debugDescription: String { get }
}

Dictionary

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
struct Dictionary<KeyType : Hashable, ValueType> : Collection, DictionaryLiteralConvertible {
  typealias _Self = Dictionary<KeyType, ValueType>
  typealias _VariantStorage = _VariantDictionaryStorage<KeyType, ValueType>
  typealias _NativeStorage = _NativeDictionaryStorage<KeyType, ValueType>
  typealias Element = (KeyType, ValueType)
  typealias Index = DictionaryIndex<KeyType, ValueType>
  var _variantStorage: _VariantDictionaryStorage<KeyType, ValueType>
  init(minimumCapacity: Int = default)
  init(_nativeStorage: _NativeDictionaryStorage<KeyType, ValueType>)
  init(_cocoaDictionary: _SwiftNSDictionary)
  var startIndex: DictionaryIndex<KeyType, ValueType> {
    get {}
  }
  var endIndex: DictionaryIndex<KeyType, ValueType> {
    get {}
  }
  func indexForKey(key: KeyType) -> DictionaryIndex<KeyType, ValueType>?
  subscript (i: DictionaryIndex<KeyType, ValueType>) -> (KeyType, ValueType) {
    get {}
  }
  subscript (key: KeyType) -> ValueType? {
    get {}
    set(newValue) {}
  }
  func updateValue(value: ValueType, forKey key: KeyType) -> ValueType?
  func removeAtIndex(index: DictionaryIndex<KeyType, ValueType>)
  func removeValueForKey(key: KeyType) -> ValueType?
  func removeAll(keepCapacity: Bool = default)
  var count: Int {
    get {}
  }
  func generate() -> DictionaryGenerator<KeyType, ValueType>
  static func convertFromDictionaryLiteral(elements: (KeyType, ValueType)...) -> Dictionary<KeyType, ValueType>
  var keys: MapCollectionView<Dictionary<KeyType, ValueType>, KeyType> {
    get {}
  }
  var values: MapCollectionView<Dictionary<KeyType, ValueType>, ValueType> {
    get {}
  }
}
extension Dictionary<KeyType, ValueType> : Printable, DebugPrintable {
  func _makeDescription(#isDebug: Bool) -> String
  var description: String {
    get {}
  }
  var debugDescription: String {
    get {}
  }
}
extension Dictionary<KeyType, ValueType> : Reflectable {
  func getMirror() -> Mirror
}

DictionaryGenerator

1
2
3
4
5
6
7
8
9
10
enum DictionaryGenerator<KeyType : Hashable, ValueType> : Generator {
  typealias _NativeIndex = _NativeDictionaryIndex<KeyType, ValueType>
  case _Native(start: _NativeDictionaryIndex<KeyType, ValueType>, end: _NativeDictionaryIndex<KeyType, ValueType>)
  case _Cocoa(_CocoaDictionaryGenerator)
  var _guaranteedNative: Bool {
    @transparent get {}
  }
  func _nativeNext() -> (KeyType, ValueType)?
  func next() -> (KeyType, ValueType)?
}

DictionaryIndex

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
enum DictionaryIndex<KeyType : Hashable, ValueType> : BidirectionalIndex {
  typealias _NativeIndex = _NativeDictionaryIndex<KeyType, ValueType>
  typealias _CocoaIndex = _CocoaDictionaryIndex
  case _Native(_NativeDictionaryIndex<KeyType, ValueType>)
  case _Cocoa(_CocoaIndex)
  var _guaranteedNative: Bool {
    @transparent get {}
  }
  var _nativeIndex: _NativeDictionaryIndex<KeyType, ValueType> {
    @transparent get {}
  }
  var _cocoaIndex: _CocoaIndex {
    @transparent get {}
  }
  typealias Index = DictionaryIndex<KeyType, ValueType>
  func pred() -> DictionaryIndex<KeyType, ValueType>
  func succ() -> DictionaryIndex<KeyType, ValueType>
}

DictionaryLiteralConvertible

1
2
3
4
5
protocol DictionaryLiteralConvertible {
  typealias Key
  typealias Value
  class func convertFromDictionaryLiteral(elements: (Key, Value)...) -> Self
}

Double

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
struct Double {
  var value: FPIEEE64
  @transparent init()
  @transparent init(_ v: FPIEEE64)
  @transparent init(_ value: Double)
}
extension Double : Printable {
  var description: String {
    get {}
  }
}
extension Double : FloatingPointNumber {
  typealias _BitsType = UInt64
  static func _fromBitPattern(bits: _BitsType) -> Double
  func _toBitPattern() -> _BitsType
  func __getSignBit() -> Int
  func __getBiasedExponent() -> _BitsType
  func __getSignificand() -> _BitsType
  static var infinity: Double {
    get {}
  }
  static var NaN: Double {
    get {}
  }
  static var quietNaN: Double {
    get {}
  }
  var isSignMinus: Bool {
    get {}
  }
  var isNormal: Bool {
    get {}
  }
  var isFinite: Bool {
    get {}
  }
  var isZero: Bool {
    get {}
  }
  var isSubnormal: Bool {
    get {}
  }
  var isInfinite: Bool {
    get {}
  }
  var isNaN: Bool {
    get {}
  }
  var isSignaling: Bool {
    get {}
  }
}
extension Double {
  var floatingPointClass: FloatingPointClassification {
    get {}
  }
}
extension Double : _BuiltinIntegerLiteralConvertible, IntegerLiteralConvertible {
  @transparent static func _convertFromBuiltinIntegerLiteral(value: Int2048) -> Double
  @transparent static func convertFromIntegerLiteral(value: Int64) -> Double
}
extension Double : _BuiltinFloatLiteralConvertible {
  @transparent static func _convertFromBuiltinFloatLiteral(value: FPIEEE64) -> Double
}
extension Double : FloatLiteralConvertible {
  @transparent static func convertFromFloatLiteral(value: Double) -> Double
}
extension Double : Comparable {
}
extension Double : Hashable {
  var hashValue: Int {
    get {}
  }
}
extension Double : AbsoluteValuable {
  @transparent static func abs(x: Double) -> Double
}
extension Double {
  @transparent init(_ v: UInt8)
  @transparent init(_ v: Int8)
  @transparent init(_ v: UInt16)
  @transparent init(_ v: Int16)
  @transparent init(_ v: UInt32)
  @transparent init(_ v: Int32)
  @transparent init(_ v: UInt64)
  @transparent init(_ v: Int64)
  @transparent init(_ v: UInt)
  @transparent init(_ v: Int)
}
extension Double {
  @transparent init(_ v: Float)
  @transparent init(_ v: Float80)
}
extension Double : RandomAccessIndex {
  @transparent func succ() -> Double
  @transparent func pred() -> Double
  @transparent func distanceTo(other: Double) -> Int
  @transparent func advancedBy(amount: Int) -> Double
}
extension Float64 : Reflectable {
  func getMirror() -> Mirror
}
extension Double : CVarArg {
  func encode() -> Word[]
}

EmptyCollection

1
2
3
4
5
6
7
8
9
10
11
12
13
14
struct EmptyCollection<T> : Collection {
  typealias IndexType = Int
  var startIndex: IndexType {
    get {}
  }
  var endIndex: IndexType {
    get {}
  }
  func generate() -> EmptyGenerator<T>
  subscript (i: IndexType) -> T {
    get {}
  }
  init()
}

EmptyGenerator

1
2
3
4
5
struct EmptyGenerator<T> : Generator, Sequence {
  func generate() -> EmptyGenerator<T>
  func next() -> T?
  init()
}

EnumerateGenerator

1
2
3
4
5
6
7
8
9
struct EnumerateGenerator<Base : Generator> : Generator, Sequence {
  typealias Element = (index: Int, element: Base.Element)
  var base: Base
  var count: Int
  init(_ base: Base)
  func next() -> Element?
  typealias GeneratorType = EnumerateGenerator<Base>
  func generate() -> EnumerateGenerator<Base>
}

Equatable

1
2
3
protocol Equatable {
  func ==(lhs: Self, rhs: Self) -> Bool
}

ExtendedGraphemeClusterLiteralConvertible

1
2
3
4
protocol ExtendedGraphemeClusterLiteralConvertible {
  typealias ExtendedGraphemeClusterLiteralType : _BuiltinExtendedGraphemeClusterLiteralConvertible
  class func convertFromExtendedGraphemeClusterLiteral(value: ExtendedGraphemeClusterLiteralType) -> Self
}

ExtendedGraphemeClusterType

1
typealias ExtendedGraphemeClusterType = String

ExtensibleCollection

1
2
protocol ExtensibleCollection : _ExtensibleCollection {
}
1
2
3
4
5
protocol _ExtensibleCollection : Collection {
  init()
  func reserveCapacity(n: Self.IndexType.DistanceType)
  func extend<S : Sequence where `Self`.GeneratorType.Element == Self.GeneratorType.Element>(_: S)
}

FilterCollectionView

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
struct FilterCollectionView<Base : Collection> : Collection {
  typealias IndexType = FilterCollectionViewIndex<Base>
  var startIndex: FilterCollectionViewIndex<Base> {
    get {}
  }
  var endIndex: FilterCollectionViewIndex<Base> {
    get {}
  }
  subscript (index: FilterCollectionViewIndex<Base>) -> Base.GeneratorType.Element {
    get {}
  }
  func generate() -> FilterGenerator<Base.GeneratorType>
  var _base: Base
  var _include: (Base.GeneratorType.Element) -> Bool
  init(_base: Base, _include: (Base.GeneratorType.Element) -> Bool)
}

FilterCollectionViewIndex

1
2
3
4
5
6
7
8
struct FilterCollectionViewIndex<Base : Collection> : ForwardIndex {
  func succ() -> FilterCollectionViewIndex<Base>
  var _pos: Base.IndexType
  var _end: Base.IndexType
  var _base: Base
  var _include: (Base.GeneratorType.Element) -> Bool
  init(_pos: Base.IndexType, _end: Base.IndexType, _base: Base, _include: (Base.GeneratorType.Element) -> Bool)
}

FilterGenerator

1
2
3
4
5
6
7
struct FilterGenerator<Base : Generator> : Generator, Sequence {
  func next() -> Base.Element?
  func generate() -> FilterGenerator<Base>
  var _base: Base
  var _include: (Base.Element) -> Bool
  init(_base: Base, _include: (Base.Element) -> Bool)
}

FilterSequenceView

1
2
3
4
5
6
struct FilterSequenceView<Base : Sequence> : Sequence {
  func generate() -> FilterGenerator<Base.GeneratorType>
  var _base: Base
  var _include: (Base.GeneratorType.Element) -> Bool
  init(_base: Base, _include: (Base.GeneratorType.Element) -> Bool)
}

Float

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
struct Float {
  var value: FPIEEE32
  @transparent init()
  @transparent init(_ v: FPIEEE32)
  @transparent init(_ value: Float)
}
extension Float : Printable {
  var description: String {
    get {}
  }
}
extension Float : FloatingPointNumber {
  typealias _BitsType = UInt32
  static func _fromBitPattern(bits: _BitsType) -> Float
  func _toBitPattern() -> _BitsType
  func __getSignBit() -> Int
  func __getBiasedExponent() -> _BitsType
  func __getSignificand() -> _BitsType
  static var infinity: Float {
    get {}
  }
  static var NaN: Float {
    get {}
  }
  static var quietNaN: Float {
    get {}
  }
  var isSignMinus: Bool {
    get {}
  }
  var isNormal: Bool {
    get {}
  }
  var isFinite: Bool {
    get {}
  }
  var isZero: Bool {
    get {}
  }
  var isSubnormal: Bool {
    get {}
  }
  var isInfinite: Bool {
    get {}
  }
  var isNaN: Bool {
    get {}
  }
  var isSignaling: Bool {
    get {}
  }
}
extension Float {
  var floatingPointClass: FloatingPointClassification {
    get {}
  }
}
extension Float : _BuiltinIntegerLiteralConvertible, IntegerLiteralConvertible {
  @transparent static func _convertFromBuiltinIntegerLiteral(value: Int2048) -> Float
  @transparent static func convertFromIntegerLiteral(value: Int64) -> Float
}
extension Float : _BuiltinFloatLiteralConvertible {
  @transparent static func _convertFromBuiltinFloatLiteral(value: FPIEEE64) -> Float
}
extension Float : FloatLiteralConvertible {
  @transparent static func convertFromFloatLiteral(value: Float) -> Float
}
extension Float : Comparable {
}
extension Float : Hashable {
  var hashValue: Int {
    get {}
  }
}
extension Float : AbsoluteValuable {
  @transparent static func abs(x: Float) -> Float
}
extension Float {
  @transparent init(_ v: UInt8)
  @transparent init(_ v: Int8)
  @transparent init(_ v: UInt16)
  @transparent init(_ v: Int16)
  @transparent init(_ v: UInt32)
  @transparent init(_ v: Int32)
  @transparent init(_ v: UInt64)
  @transparent init(_ v: Int64)
  @transparent init(_ v: UInt)
  @transparent init(_ v: Int)
}
extension Float {
  @transparent init(_ v: Double)
  @transparent init(_ v: Float80)
}
extension Float : RandomAccessIndex {
  @transparent func succ() -> Float
  @transparent func pred() -> Float
  @transparent func distanceTo(other: Float) -> Int
  @transparent func advancedBy(amount: Int) -> Float
}
extension Float32 : Reflectable {
  func getMirror() -> Mirror
}
extension Float : CVarArg {
  func encode() -> Word[]
}

Float32

1
typealias Float32 = Float

Float64

1
typealias Float64 = Double

Float80

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
struct Float80 {
  var value: FPIEEE80
  @transparent init()
  @transparent init(_ v: FPIEEE80)
  @transparent init(_ value: Float80)
}
extension Float80 : Printable {
  var description: String {
    get {}
  }
}
extension Float80 : _BuiltinIntegerLiteralConvertible, IntegerLiteralConvertible {
  @transparent static func _convertFromBuiltinIntegerLiteral(value: Int2048) -> Float80
  @transparent static func convertFromIntegerLiteral(value: Int64) -> Float80
}
extension Float80 : _BuiltinFloatLiteralConvertible {
  @transparent static func _convertFromBuiltinFloatLiteral(value: FPIEEE64) -> Float80
}
extension Float80 : FloatLiteralConvertible {
  @transparent static func convertFromFloatLiteral(value: Float80) -> Float80
}
extension Float80 : Comparable {
}
extension Float80 : Hashable {
  var hashValue: Int {
    get {}
  }
}
extension Float80 : AbsoluteValuable {
  @transparent static func abs(x: Float80) -> Float80
}
extension Float80 {
  @transparent init(_ v: UInt8)
  @transparent init(_ v: Int8)
  @transparent init(_ v: UInt16)
  @transparent init(_ v: Int16)
  @transparent init(_ v: UInt32)
  @transparent init(_ v: Int32)
  @transparent init(_ v: UInt64)
  @transparent init(_ v: Int64)
  @transparent init(_ v: UInt)
  @transparent init(_ v: Int)
}
extension Float80 {
  @transparent init(_ v: Float)
  @transparent init(_ v: Double)
}
extension Float80 : RandomAccessIndex {
  @transparent func succ() -> Float80
  @transparent func pred() -> Float80
  @transparent func distanceTo(other: Float80) -> Int
  @transparent func advancedBy(amount: Int) -> Float80
}

FloatingPointClassification

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
enum FloatingPointClassification {
  case SignalingNaN
  case QuietNaN
  case NegativeInfinity
  case NegativeNormal
  case NegativeSubnormal
  case NegativeZero
  case PositiveZero
  case PositiveSubnormal
  case PositiveNormal
  case PositiveInfinity
  var hashValue: Int {
    get {}
  }
}
extension FloatingPointClassification : Equatable {
}

FloatingPointNumber

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
protocol FloatingPointNumber {
  typealias _BitsType
  class func _fromBitPattern(bits: _BitsType) -> Self
  func _toBitPattern() -> _BitsType
  class var infinity: Self { get }
  class var NaN: Self { get }
  class var quietNaN: Self { get }
  var floatingPointClass: FloatingPointClassification { get }
  var isSignMinus: Bool { get }
  var isNormal: Bool { get }
  var isFinite: Bool { get }
  var isZero: Bool { get }
  var isSubnormal: Bool { get }
  var isInfinite: Bool { get }
  var isNaN: Bool { get }
  var isSignaling: Bool { get }
}

FloatLiteralConvertible

1
2
3
4
protocol FloatLiteralConvertible {
  typealias FloatLiteralType : _BuiltinFloatLiteralConvertible
  class func convertFromFloatLiteral(value: FloatLiteralType) -> Self
}

FloatLiteralType

1
typealias FloatLiteralType = Double

ForwardIndex

1
2
3
4
5
protocol ForwardIndex : _ForwardIndex {
  func ~>(start: Self, _: (_Distance, Self)) -> Self.DistanceType
  func ~>(start: Self, _: (_Advance, Self.DistanceType)) -> Self
  func ~>(start: Self, _: (_Advance, (Self.DistanceType, Self))) -> Self
}

Generator

1
2
3
4
protocol Generator {
  typealias Element
  func next() -> Element?
}

GeneratorOf

1
2
3
4
5
6
7
struct GeneratorOf<T> : Generator, Sequence {
  init(_ next: () -> T?)
  init<G : Generator where T == T>(_ self_: G)
  func next() -> T?
  func generate() -> GeneratorOf<T>
  let _next: () -> T?
}

GeneratorOfOne

1
2
3
4
5
6
struct GeneratorOfOne<T> : Generator, Sequence {
  init(_ elements: T?)
  func generate() -> GeneratorOfOne<T>
  func next() -> T?
  var elements: T?
}

GeneratorSequence

1
2
3
4
5
6
struct GeneratorSequence<G : Generator> : Generator, Sequence {
  init(_ base: G)
  func next() -> G.Element?
  func generate() -> GeneratorSequence<G>
  var _base: G
}

Hashable

1
2
3
protocol Hashable : Equatable {
  var hashValue: Int { get }
}

HeapBuffer

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
struct HeapBuffer<Value, Element> : LogicValue, Equatable {
  typealias Storage = HeapBufferStorage<Value, Element>
  let storage: HeapBufferStorage<Value, Element>?
  static func _valueOffset() -> Int
  static func _elementOffset() -> Int
  static func _requiredAlignMask() -> Int
  var _address: UnsafePointer<Int8> {
    get {}
  }
  var _value: UnsafePointer<Value> {
    get {}
  }
  var elementStorage: UnsafePointer<Element> {
    get {}
  }
  func _allocatedSize() -> Int
  func _allocatedAlignMask() -> Int
  func _allocatedSizeAndAlignMask() -> (Int, Int)
  func _capacity() -> Int
  init()
  init(_ storage: HeapBufferStorage<Value, Element>)
  init(_ storageClass: HeapBufferStorageBase.Type, _ initializer: Value, _ capacity: Int)
  var value: Value {
    get {}
    set(newValue) {}
  }
  func getLogicValue() -> Bool
  subscript (i: Int) -> Element {
    get {}
    set(newValue) {}
  }
  @conversion func __conversion() -> NativeObject
  static func fromNativeObject(x: NativeObject) -> HeapBuffer<Value, Element>
  func isUniquelyReferenced() -> Bool
}

HeapBufferStorage

1
2
3
4
5
6
@objc class HeapBufferStorage<Value, Element> : HeapBufferStorageBase {
  typealias Buffer = HeapBuffer<Value, Element>
  @objc deinit
  func __getInstanceSizeAndAlignMask() -> (Int, Int)
  init()
}

HeapBufferStorageBase

1
2
3
4
@objc class HeapBufferStorageBase {
  @objc deinit
  @objc init()
}

ImplicitlyUnwrappedOptional

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
struct ImplicitlyUnwrappedOptional<T> : LogicValue, Reflectable {
  var value: T?
  init()
  init(_ v: T?)
  static var None: ImplicitlyUnwrappedOptional<T> {
    @transparent get {}
  }
  @transparent static func Some(value: T) -> ImplicitlyUnwrappedOptional<T>
  @transparent func getLogicValue() -> Bool
  func getMirror() -> Mirror
  func map<U>(f: (T) -> U) -> ImplicitlyUnwrappedOptional<U>
}
extension ImplicitlyUnwrappedOptional<T> : Printable {
  var description: String {
    get {}
  }
}
extension ImplicitlyUnwrappedOptional<T> : _ConditionallyBridgedToObjectiveC {
  typealias ObjectiveCType = AnyObject
  static func getObjectiveCType() -> Any.Type
  func bridgeToObjectiveC() -> AnyObject
  static func bridgeFromObjectiveC(x: AnyObject) -> T!?
  static func isBridgedToObjectiveC() -> Bool
}

IndexingGenerator

1
2
3
4
5
6
7
struct IndexingGenerator<C : _Collection> : Generator, Sequence {
  init(_ seq: C)
  func generate() -> IndexingGenerator<C>
  func next() -> C._Element?
  var _elements: C
  var _position: C.IndexType
}

IndirectArrayBuffer

1
2
3
4
5
6
7
8
9
10
11
12
13
@final class IndirectArrayBuffer {
  init<T>(nativeBuffer: ContiguousArrayBuffer<T>, isMutable: Bool, needsElementTypeCheck: Bool)
  init(cocoa: _CocoaArray, needsElementTypeCheck: Bool)
  init<Target>(castFrom source: IndirectArrayBuffer, toElementType _: Target.Type)
  @final @final @final func replaceStorage<T>(newBuffer: ContiguousArrayBuffer<T>)
  var buffer: AnyObject?
  var isMutable: Bool
  var isCocoa: Bool
  var needsElementTypeCheck: Bool
  @final @final @final func getNativeBufferOf<T>(_: T.Type) -> ContiguousArrayBuffer<T>
  @final @final @final func getCocoa() -> _CocoaArray
  @objc deinit
}

Int

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
struct Int : SignedInteger {
  var value: Word
  @transparent init()
  @transparent init(_ v: Word)
  @transparent init(_ value: Int)
  @transparent static func _convertFromBuiltinIntegerLiteral(value: Int2048) -> Int
  @transparent static func convertFromIntegerLiteral(value: Int) -> Int
  @transparent func _getBuiltinArrayBoundValue() -> Word
  typealias ArrayBoundType = Int
  func getArrayBoundValue() -> Int
  static var max: Int {
    @transparent get {}
  }
  static var min: Int {
    @transparent get {}
  }
}
extension Int : Hashable {
  var hashValue: Int {
    get {}
  }
}
extension Int : Printable {
  var description: String {
    get {}
  }
}
extension Int : RandomAccessIndex {
  @transparent func succ() -> Int
  @transparent func pred() -> Int
  @transparent func distanceTo(other: Int) -> Int
  @transparent func advancedBy(amount: Int) -> Int
  @transparent static func uncheckedAdd(lhs: Int, _ rhs: Int) -> (Int, Bool)
  @transparent static func uncheckedSubtract(lhs: Int, _ rhs: Int) -> (Int, Bool)
  @transparent static func uncheckedMultiply(lhs: Int, _ rhs: Int) -> (Int, Bool)
  @transparent static func uncheckedDivide(lhs: Int, _ rhs: Int) -> (Int, Bool)
  @transparent static func uncheckedModulus(lhs: Int, _ rhs: Int) -> (Int, Bool)
  @transparent func toIntMax() -> IntMax
  @transparent static func from(x: IntMax) -> Int
}
extension Int : SignedNumber {
}
extension Int {
  @transparent init(_ v: UInt8)
  @transparent init(_ v: Int8)
  @transparent init(_ v: UInt16)
  @transparent init(_ v: Int16)
  @transparent init(_ v: UInt32)
  @transparent init(_ v: Int32)
  @transparent init(_ v: UInt64)
  @transparent init(_ v: Int64)
  @transparent init(_ v: UInt)
  @transparent func asUnsigned() -> UInt
}
extension Int : BitwiseOperations {
  static var allZeros: Int {
    @transparent get {}
  }
}
extension Int {
  @transparent init(_ v: Float)
  @transparent init(_ v: Double)
  @transparent init(_ v: Float80)
}
extension Int : Reflectable {
  func getMirror() -> Mirror
}
extension Int : CVarArg {
  func encode() -> Word[]
}

Int16

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
struct Int16 : SignedInteger {
  var value: Int16
  @transparent init()
  @transparent init(_ v: Int16)
  @transparent init(_ value: Int16)
  @transparent static func _convertFromBuiltinIntegerLiteral(value: Int2048) -> Int16
  @transparent static func convertFromIntegerLiteral(value: Int16) -> Int16
  @transparent func _getBuiltinArrayBoundValue() -> Word
  typealias ArrayBoundType = Int16
  func getArrayBoundValue() -> Int16
  static var max: Int16 {
    @transparent get {}
  }
  static var min: Int16 {
    @transparent get {}
  }
}
extension Int16 : Hashable {
  var hashValue: Int {
    get {}
  }
}
extension Int16 : Printable {
  var description: String {
    get {}
  }
}
extension Int16 : RandomAccessIndex {
  @transparent func succ() -> Int16
  @transparent func pred() -> Int16
  @transparent func distanceTo(other: Int16) -> Int
  @transparent func advancedBy(amount: Int) -> Int16
  @transparent static func uncheckedAdd(lhs: Int16, _ rhs: Int16) -> (Int16, Bool)
  @transparent static func uncheckedSubtract(lhs: Int16, _ rhs: Int16) -> (Int16, Bool)
  @transparent static func uncheckedMultiply(lhs: Int16, _ rhs: Int16) -> (Int16, Bool)
  @transparent static func uncheckedDivide(lhs: Int16, _ rhs: Int16) -> (Int16, Bool)
  @transparent static func uncheckedModulus(lhs: Int16, _ rhs: Int16) -> (Int16, Bool)
  @transparent func toIntMax() -> IntMax
  @transparent static func from(x: IntMax) -> Int16
}
extension Int16 : SignedNumber {
}
extension Int16 {
  @transparent init(_ v: UInt8)
  @transparent init(_ v: Int8)
  @transparent init(_ v: UInt16)
  @transparent init(_ v: UInt32)
  @transparent init(_ v: Int32)
  @transparent init(_ v: UInt64)
  @transparent init(_ v: Int64)
  @transparent init(_ v: UInt)
  @transparent init(_ v: Int)
  @transparent func asUnsigned() -> UInt16
}
extension Int16 : BitwiseOperations {
  static var allZeros: Int16 {
    @transparent get {}
  }
}
extension Int16 {
  @transparent init(_ v: Float)
  @transparent init(_ v: Double)
  @transparent init(_ v: Float80)
}
extension Int16 : Reflectable {
  func getMirror() -> Mirror
}
extension Int16 : CVarArg {
  func encode() -> Word[]
}

Int32

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
struct Int32 : SignedInteger {
  var value: Int32
  @transparent init()
  @transparent init(_ v: Int32)
  @transparent init(_ value: Int32)
  @transparent static func _convertFromBuiltinIntegerLiteral(value: Int2048) -> Int32
  @transparent static func convertFromIntegerLiteral(value: Int32) -> Int32
  @transparent func _getBuiltinArrayBoundValue() -> Word
  typealias ArrayBoundType = Int32
  func getArrayBoundValue() -> Int32
  static var max: Int32 {
    @transparent get {}
  }
  static var min: Int32 {
    @transparent get {}
  }
}
extension Int32 : Hashable {
  var hashValue: Int {
    get {}
  }
}
extension Int32 : Printable {
  var description: String {
    get {}
  }
}
extension Int32 : RandomAccessIndex {
  @transparent func succ() -> Int32
  @transparent func pred() -> Int32
  @transparent func distanceTo(other: Int32) -> Int
  @transparent func advancedBy(amount: Int) -> Int32
  @transparent static func uncheckedAdd(lhs: Int32, _ rhs: Int32) -> (Int32, Bool)
  @transparent static func uncheckedSubtract(lhs: Int32, _ rhs: Int32) -> (Int32, Bool)
  @transparent static func uncheckedMultiply(lhs: Int32, _ rhs: Int32) -> (Int32, Bool)
  @transparent static func uncheckedDivide(lhs: Int32, _ rhs: Int32) -> (Int32, Bool)
  @transparent static func uncheckedModulus(lhs: Int32, _ rhs: Int32) -> (Int32, Bool)
  @transparent func toIntMax() -> IntMax
  @transparent static func from(x: IntMax) -> Int32
}
extension Int32 : SignedNumber {
}
extension Int32 {
  @transparent init(_ v: UInt8)
  @transparent init(_ v: Int8)
  @transparent init(_ v: UInt16)
  @transparent init(_ v: Int16)
  @transparent init(_ v: UInt32)
  @transparent init(_ v: UInt64)
  @transparent init(_ v: Int64)
  @transparent init(_ v: UInt)
  @transparent init(_ v: Int)
  @transparent func asUnsigned() -> UInt32
}
extension Int32 : BitwiseOperations {
  static var allZeros: Int32 {
    @transparent get {}
  }
}
extension Int32 {
  @transparent init(_ v: Float)
  @transparent init(_ v: Double)
  @transparent init(_ v: Float80)
}
extension Int32 : Reflectable {
  func getMirror() -> Mirror
}
extension Int32 : CVarArg {
  func encode() -> Word[]
}

Int64

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
struct Int64 : SignedInteger {
  var value: Int64
  @transparent init()
  @transparent init(_ v: Int64)
  @transparent init(_ value: Int64)
  @transparent static func _convertFromBuiltinIntegerLiteral(value: Int2048) -> Int64
  @transparent static func convertFromIntegerLiteral(value: Int64) -> Int64
  @transparent func _getBuiltinArrayBoundValue() -> Word
  typealias ArrayBoundType = Int64
  func getArrayBoundValue() -> Int64
  static var max: Int64 {
    @transparent get {}
  }
  static var min: Int64 {
    @transparent get {}
  }
}
extension Int64 : Hashable {
  var hashValue: Int {
    get {}
  }
}
extension Int64 : Printable {
  var description: String {
    get {}
  }
}
extension Int64 : RandomAccessIndex {
  @transparent func succ() -> Int64
  @transparent func pred() -> Int64
  @transparent func distanceTo(other: Int64) -> Int
  @transparent func advancedBy(amount: Int) -> Int64
  @transparent static func uncheckedAdd(lhs: Int64, _ rhs: Int64) -> (Int64, Bool)
  @transparent static func uncheckedSubtract(lhs: Int64, _ rhs: Int64) -> (Int64, Bool)
  @transparent static func uncheckedMultiply(lhs: Int64, _ rhs: Int64) -> (Int64, Bool)
  @transparent static func uncheckedDivide(lhs: Int64, _ rhs: Int64) -> (Int64, Bool)
  @transparent static func uncheckedModulus(lhs: Int64, _ rhs: Int64) -> (Int64, Bool)
  @transparent func toIntMax() -> IntMax
  @transparent static func from(x: IntMax) -> Int64
}
extension Int64 : SignedNumber {
}
extension Int64 {
  @transparent init(_ v: UInt8)
  @transparent init(_ v: Int8)
  @transparent init(_ v: UInt16)
  @transparent init(_ v: Int16)
  @transparent init(_ v: UInt32)
  @transparent init(_ v: Int32)
  @transparent init(_ v: UInt64)
  @transparent init(_ v: UInt)
  @transparent init(_ v: Int)
  @transparent func asUnsigned() -> UInt64
}
extension Int64 : BitwiseOperations {
  static var allZeros: Int64 {
    @transparent get {}
  }
}
extension Int64 {
  @transparent init(_ v: Float)
  @transparent init(_ v: Double)
  @transparent init(_ v: Float80)
}
extension Int64 : Reflectable {
  func getMirror() -> Mirror
}
extension Int64 : CVarArg {
  func encode() -> Word[]
}

Int8

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
struct Int8 : SignedInteger {
  var value: Int8
  @transparent init()
  @transparent init(_ v: Int8)
  @transparent init(_ value: Int8)
  @transparent static func _convertFromBuiltinIntegerLiteral(value: Int2048) -> Int8
  @transparent static func convertFromIntegerLiteral(value: Int8) -> Int8
  @transparent func _getBuiltinArrayBoundValue() -> Word
  typealias ArrayBoundType = Int8
  func getArrayBoundValue() -> Int8
  static var max: Int8 {
    @transparent get {}
  }
  static var min: Int8 {
    @transparent get {}
  }
}
extension Int8 : Hashable {
  var hashValue: Int {
    get {}
  }
}
extension Int8 : Printable {
  var description: String {
    get {}
  }
}
extension Int8 : RandomAccessIndex {
  @transparent func succ() -> Int8
  @transparent func pred() -> Int8
  @transparent func distanceTo(other: Int8) -> Int
  @transparent func advancedBy(amount: Int) -> Int8
  @transparent static func uncheckedAdd(lhs: Int8, _ rhs: Int8) -> (Int8, Bool)
  @transparent static func uncheckedSubtract(lhs: Int8, _ rhs: Int8) -> (Int8, Bool)
  @transparent static func uncheckedMultiply(lhs: Int8, _ rhs: Int8) -> (Int8, Bool)
  @transparent static func uncheckedDivide(lhs: Int8, _ rhs: Int8) -> (Int8, Bool)
  @transparent static func uncheckedModulus(lhs: Int8, _ rhs: Int8) -> (Int8, Bool)
  @transparent func toIntMax() -> IntMax
  @transparent static func from(x: IntMax) -> Int8
}
extension Int8 : SignedNumber {
}
extension Int8 {
  @transparent init(_ v: UInt8)
  @transparent init(_ v: UInt16)
  @transparent init(_ v: Int16)
  @transparent init(_ v: UInt32)
  @transparent init(_ v: Int32)
  @transparent init(_ v: UInt64)
  @transparent init(_ v: Int64)
  @transparent init(_ v: UInt)
  @transparent init(_ v: Int)
  @transparent func asUnsigned() -> UInt8
}
extension Int8 : BitwiseOperations {
  static var allZeros: Int8 {
    @transparent get {}
  }
}
extension Int8 {
  @transparent init(_ v: Float)
  @transparent init(_ v: Double)
  @transparent init(_ v: Float80)
}
extension Int8 : Reflectable {
  func getMirror() -> Mirror
}
extension Int8 : CVarArg {
  func encode() -> Word[]
}

Integer

1
2
3
4
5
protocol Integer : _Integer, RandomAccessIndex {
}

protocol _Integer : _BuiltinIntegerLiteralConvertible, IntegerLiteralConvertible, Printable, ArrayBound, Hashable, IntegerArithmetic, BitwiseOperations, _Incrementable {
}

IntegerArithmetic

1
2
3
4
5
6
7
8
protocol IntegerArithmetic : _IntegerArithmetic, Comparable {
  func +(lhs: Self, rhs: Self) -> Self
  func -(lhs: Self, rhs: Self) -> Self
  func *(lhs: Self, rhs: Self) -> Self
  func /(lhs: Self, rhs: Self) -> Self
  func %(lhs: Self, rhs: Self) -> Self
  func toIntMax() -> IntMax
}

IntegerLiteralConvertible

1
2
3
4
protocol IntegerLiteralConvertible {
  typealias IntegerLiteralType : _BuiltinIntegerLiteralConvertible
  class func convertFromIntegerLiteral(value: IntegerLiteralType) -> Self
}

IntegerLiteralType

1
typealias IntegerLiteralType = Int

IntEncoder

1
2
3
4
5
6
7
struct IntEncoder : Sink {
  var asInt: UInt64
  var shift: UInt64
  func put(x: CodeUnit)
  init(asInt: UInt64, shift: UInt64)
  init()
}

IntMax

1
typealias IntMax = Int64

Less

1
2
3
4
struct Less<T : Comparable> {
  static func compare(x: T, _ y: T) -> Bool
  init()
}

LifetimeManager

1
2
3
4
5
6
7
8
class LifetimeManager {
  var _managedRefs: NativeObject[]
  var _releaseCalled: Bool
  init()
  @objc deinit
  func put(objPtr: NativeObject)
  func release()
}

LogicValue

1
2
3
protocol LogicValue {
  func getLogicValue() -> Bool
}

MapCollectionView

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
struct MapCollectionView<Base : Collection, T> : Collection {
  var startIndex: Base.IndexType {
    get {}
  }
  var endIndex: Base.IndexType {
    get {}
  }
  subscript (index: Base.IndexType) -> T {
    get {}
  }
  func generate() -> MapSequenceGenerator<Base.GeneratorType, T>
  var _base: Base
  var _transform: (Base.GeneratorType.Element) -> T
  init(_base: Base, _transform: (Base.GeneratorType.Element) -> T)
}

MapSequenceGenerator

1
2
3
4
5
6
7
struct MapSequenceGenerator<Base : Generator, T> : Generator, Sequence {
  func next() -> T?
  func generate() -> MapSequenceGenerator<Base, T>
  var _base: Base
  var _transform: (Base.Element) -> T
  init(_base: Base, _transform: (Base.Element) -> T)
}

MapSequenceView

1
2
3
4
5
6
struct MapSequenceView<Base : Sequence, T> : Sequence {
  func generate() -> MapSequenceGenerator<Base.GeneratorType, T>
  var _base: Base
  var _transform: (Base.GeneratorType.Element) -> T
  init(_base: Base, _transform: (Base.GeneratorType.Element) -> T)
}

MaxBuiltinFloatType

1
typealias MaxBuiltinFloatType = FPIEEE64

MaxBuiltinIntegerType

1
typealias MaxBuiltinIntegerType = Int2048

Mirror

1
2
3
4
5
6
7
8
9
10
protocol Mirror {
  var value: Any { get }
  var valueType: Any.Type { get }
  var objectIdentifier: ObjectIdentifier? { get }
  var count: Int { get }
  subscript (i: Int) -> (String, Mirror) { get }
  var summary: String { get }
  var quickLookObject: QuickLookObject? { get }
  var disposition: MirrorDisposition { get }
}

MirrorDisposition

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
enum MirrorDisposition {
  case Struct
  case Class
  case Enum
  case Tuple
  case Aggregate
  case IndexContainer
  case KeyContainer
  case MembershipContainer
  case Container
  case Optional
  var hashValue: Int {
    get {}
  }
}

MutableCollection

1
2
3
protocol MutableCollection : Collection {
  subscript (i: Self.IndexType) -> Self.GeneratorType.Element { get set }
}

MutableSliceable

1
2
3
protocol MutableSliceable : Sliceable, MutableCollection {
  subscript (_: Range<Self.IndexType>) -> Self.SliceType { get set }
}

ObjectIdentifier

1
2
3
4
5
6
7
8
struct ObjectIdentifier : Hashable {
  let value: RawPointer
  func uintValue() -> UInt
  var hashValue: Int {
    get {}
  }
  init(_ x: AnyObject)
}

OnHeap

1
2
3
4
5
6
struct OnHeap<T> {
  typealias Buffer = HeapBuffer<T, Void>
  init(_ value: T)
  @conversion func __conversion() -> T
  var _storage: HeapBuffer<T, Void>
}

Optional

This is the alias of Type? .

1
2
3
4
5
6
7
8
9
10
11
12
13
14
enum Optional<T> : LogicValue, Reflectable {
  case None
  case Some(T)
  init()
  init(_ some: T)
  @transparent func getLogicValue() -> Bool
  func map<U>(f: (T) -> U) -> U?
  func getMirror() -> Mirror
}
extension Optional<T> : Printable {
  var description: String {
    get {}
  }
}

OutputStream

1
2
3
protocol OutputStream {
  func write(string: String)
}

PermutationGenerator

1
2
3
4
5
6
7
8
9
struct PermutationGenerator<C : Collection, Indices : Sequence where C.IndexType == C.IndexType> : Generator, Sequence {
  var seq: C
  var indices: Indices.GeneratorType
  typealias Element = C.GeneratorType.Element
  func next() -> Element?
  typealias GeneratorType = PermutationGenerator<C, Indices>
  func generate() -> PermutationGenerator<C, Indices>
  init(elements seq: C, indices: Indices)
}

Printable

1
2
3
protocol Printable {
  var description: String { get }
}

QuickLookObject

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
enum QuickLookObject {
  case Text(String)
  case Int(Int64)
  case UInt(UInt64)
  case Float(Double)
  case Image(Any)
  case Sound(Any)
  case Color(Any)
  case BezierPath(Any)
  case AttributedString(Any)
  case Rectangle(Double, Double, Double, Double)
  case Point(Double, Double)
  case Size(Double, Double)
  case Logical(Bool)
  case Range(UInt64, UInt64)
  case View(Any)
  case Sprite(Any)
  case URL(String)
  case _Raw(UInt8[], String)
}

RandomAccessIndex

1
2
3
4
5
protocol RandomAccessIndex : BidirectionalIndex, _RandomAccessIndex {}
protocol _RandomAccessIndex : _BidirectionalIndex {
  func distanceTo(_: Self) -> Self.DistanceType
  func advancedBy(_: Self.DistanceType) -> Self
}

Range

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
struct Range<T : ForwardIndex> : LogicValue, Sliceable {
  @transparent init(start: T, end: T)
  var isEmpty: Bool {
    get {}
  }
  func getLogicValue() -> Bool
  subscript (i: T) -> T {
    get {}
  }
  subscript (x: Range<T>) -> Range<T> {
    get {}
  }
  typealias GeneratorType = RangeGenerator<T>
  func generate() -> RangeGenerator<T>
  func by(stride: T.DistanceType) -> StridedRangeGenerator<T>
  var startIndex: T {
    get {}
    set(newValue) {}
  }
  var endIndex: T {
    get {}
    set(newValue) {}
  }
  var _startIndex: T
  var _endIndex: T
}

RangeGenerator

1
2
3
4
5
6
7
8
9
struct RangeGenerator<T : ForwardIndex> : Generator, Sequence {
  typealias Element = T
  @transparent init(_ bounds: Range<T>)
  func next() -> T?
  typealias GeneratorType = RangeGenerator<T>
  func generate() -> RangeGenerator<T>
  var startIndex: T
  var endIndex: T
}

RawByte

1
2
3
4
struct RawByte {
  let _inaccessible: UInt8
  init(_inaccessible: UInt8)
}

RawOptionSet

1
2
3
protocol RawOptionSet : _RawOptionSet, LogicValue, Equatable {
  class func fromMask(raw: Self.RawType) -> Self
}

RawRepresentable

1
2
3
4
5
protocol RawRepresentable {
  typealias RawType
  class func fromRaw(raw: RawType) -> Self?
  func toRaw() -> RawType
}

Reflectable

1
2
3
protocol Reflectable {
  func getMirror() -> Mirror
}

Repeat

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
struct Repeat<T> : Collection {
  typealias IndexType = Int
  init(count: Int, repeatedValue: T)
  var startIndex: IndexType {
    get {}
  }
  var endIndex: IndexType {
    get {}
  }
  func generate() -> IndexingGenerator<Repeat<T>>
  subscript (i: Int) -> T {
    get {}
  }
  var count: Int
  let repeatedValue: T
}

ReverseIndex

1
2
3
4
5
6
struct ReverseIndex<I : BidirectionalIndex> : BidirectionalIndex {
  var _base: I
  init(_ _base: I)
  func succ() -> ReverseIndex<I>
  func pred() -> ReverseIndex<I>
}

ReverseRange

1
2
3
4
5
6
7
8
9
struct ReverseRange<T : BidirectionalIndex> : Sequence {
  init(start: T, pastEnd: T)
  init(range fwd: Range<T>)
  func isEmpty() -> Bool
  func bounds() -> (T, T)
  typealias GeneratorType = ReverseRangeGenerator<T>
  func generate() -> ReverseRangeGenerator<T>
  var _bounds: (T, T)
}

ReverseRangeGenerator

1
2
3
4
5
6
7
8
struct ReverseRangeGenerator<T : BidirectionalIndex> : Generator, Sequence {
  typealias Element = T
  @transparent init(start: T, pastEnd: T)
  func next() -> T?
  typealias GeneratorType = ReverseRangeGenerator<T>
  func generate() -> ReverseRangeGenerator<T>
  var _bounds: (T, T)
}

ReverseView

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
struct ReverseView<T : Collection where T.IndexType : BidirectionalIndex> : Collection {
  typealias IndexType = ReverseIndex<T.IndexType>
  typealias GeneratorType = IndexingGenerator<ReverseView<T>>
  init(_ _base: T)
  func generate() -> IndexingGenerator<ReverseView<T>>
  var startIndex: IndexType {
    get {}
  }
  var endIndex: IndexType {
    get {}
  }
  subscript (i: IndexType) -> T.GeneratorType.Element {
    get {}
  }
  var _base: T
}

Sequence

1
2
3
4
5
6
7
protocol Sequence : _Sequence_ {
  typealias GeneratorType : Generator
  func generate() -> GeneratorType
  func ~>(_: Self, _: (_UnderestimateCount, ())) -> Int
  func ~><R>(_: Self, _: (_PreprocessingPass, ((Self) -> R))) -> R?
  func ~>(_: Self, _: (_CopyToNativeArrayBuffer, ())) -> ContiguousArrayBuffer<Self.GeneratorType.Element>
}

SequenceOf

1
2
3
4
5
6
struct SequenceOf<T> : Sequence {
  init<G : Generator where T == T>(_ generate: () -> G)
  init<S : Sequence where T == T>(_ self_: S)
  func generate() -> GeneratorOf<T>
  let _generate: () -> GeneratorOf<T>
}

SignedInteger

1
2
3
4
5
6
protocol SignedInteger : _SignedInteger, Integer {
}
protocol _SignedInteger : _Integer, SignedNumber {
  func toIntMax() -> IntMax
  class func from(_: IntMax) -> Self
}

SignedNumber

1
2
3
4
protocol SignedNumber : _SignedNumber {
  func -(x: Self) -> Self
  func ~>(_: Self, _: (_Abs, ())) -> Self
}

Sink

1
2
3
4
protocol Sink {
  typealias Element
  func put(x: Element)
}

SinkOf

1
2
3
4
5
6
struct SinkOf<T> : Sink {
  init(_ put: (T) -> ())
  init<S : Sink where T == T>(_ base: S)
  func put(x: T)
  let _put: (T) -> ()
}

Slice

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
struct Slice<T> : MutableCollection, Sliceable {
  typealias Element = T
  var startIndex: Int {
    get {}
  }
  var endIndex: Int {
    get {}
  }
  subscript (index: Int) -> T {
    get {}
    set {}
  }
  func generate() -> IndexingGenerator<Slice<T>>
  typealias SliceType = Slice<T>
  subscript (subRange: Range<Int>) -> Slice<T> {
    get {}
    set(rhs) {}
  }
  typealias _Buffer = SliceBuffer<T>
  init(_ buffer: SliceBuffer<T>)
  var _buffer: SliceBuffer<T>
}
extension Slice<T> : ArrayLiteralConvertible {
  static func convertFromArrayLiteral(elements: T...) -> Slice<T>
}
extension Slice<T> {
  func _asCocoaArray() -> _CocoaArray
}
extension Slice<T> : ArrayType {
  init()
  init<S : Sequence where T == T>(_ s: S)
  init(count: Int, repeatedValue: T)
  var count: Int {
    get {}
  }
  var capacity: Int {
    get {}
  }
  var isEmpty: Bool {
    get {}
  }
  var _owner: AnyObject? {
    get {}
  }
  var _elementStorageIfContiguous: UnsafePointer<T> {
    get {}
  }
  var _elementStorage: UnsafePointer<T> {
    get {}
  }
  func copy() -> Slice<T>
  func unshare()
  func reserveCapacity(minimumCapacity: Int)
  func append(newElement: T)
  func extend<S : Sequence where T == T>(sequence: S)
  func removeLast() -> T
  func insert(newElement: T, atIndex: Int)
  func removeAtIndex(index: Int) -> T
  func removeAll(keepCapacity: Bool = default)
  func join<S : Sequence where Slice<T> == Slice<T>>(elements: S) -> Slice<T>
  func reduce<U>(initial: U, combine: (U, T) -> U) -> U
  func sort(isOrderedBefore: (T, T) -> Bool)
  func map<U>(transform: (T) -> U) -> Slice<U>
  func reverse() -> Slice<T>
  func filter(includeElement: (T) -> Bool) -> Slice<T>
}
extension Slice<T> : Reflectable {
  func getMirror() -> Mirror
}
extension Slice<T> : Printable, DebugPrintable {
  func _makeDescription(#isDebug: Bool) -> String
  var description: String {
    get {}
  }
  var debugDescription: String {
    get {}
  }
}
extension Slice<T> {
  @transparent func _cPointerArgs() -> (AnyObject?, RawPointer)
  @conversion @transparent func __conversion() -> CConstPointer<T>
  @conversion @transparent func __conversion() -> CConstVoidPointer
}
extension Slice<T> {
  func withUnsafePointerToElements<R>(body: (UnsafePointer<T>) -> R) -> R
}
extension Slice<T> {
  func replaceRange<C : Collection where T == T>(subRange: Range<Int>, with newValues: C)
}

Sliceable

1
2
3
4
protocol Sliceable : _Sliceable {
  typealias SliceType : _Sliceable
  subscript (_: Range<Self.IndexType>) -> SliceType { get }
}

SliceBuffer

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
struct SliceBuffer<T> : ArrayBufferType {
  typealias Element = T
  typealias NativeStorage = ContiguousArrayStorage<T>
  typealias NativeBuffer = ContiguousArrayBuffer<T>
  init(owner: AnyObject?, start: UnsafePointer<T>, count: Int, hasNativeBuffer: Bool)
  init()
  init(_ buffer: ContiguousArrayBuffer<T>)
  func _invariantCheck()
  var _hasNativeBuffer: Bool {
    get {}
  }
  var nativeBuffer: ContiguousArrayBuffer<T> {
    get {}
  }
  var identity: Word {
    get {}
  }
  var owner: AnyObject?
  var start: UnsafePointer<T>
  var _countAndFlags: UInt
  func _asCocoaArray() -> _CocoaArray
  func requestUniqueMutableBuffer(minimumCapacity: Int) -> ContiguousArrayBuffer<T>?
  func requestNativeBuffer() -> ContiguousArrayBuffer<T>?
  func _uninitializedCopy(subRange: Range<Int>, target: UnsafePointer<T>) -> UnsafePointer<T>
  var elementStorage: UnsafePointer<T> {
    get {}
  }
  var count: Int {
    get {}
    set {}
  }
  var capacity: Int {
    get {}
  }
  func isUniquelyReferenced() -> Bool
  subscript (i: Int) -> T {
    get {}
    set {}
  }
  subscript (subRange: Range<Int>) -> SliceBuffer<T> {
    get {}
  }
  var startIndex: Int {
    get {}
  }
  var endIndex: Int {
    get {}
  }
  func generate() -> IndexingGenerator<SliceBuffer<T>>
  func withUnsafePointerToElements<R>(body: (UnsafePointer<T>) -> R) -> R
}

StaticString

1
2
3
4
5
6
7
8
9
10
11
struct StaticString : _BuiltinExtendedGraphemeClusterLiteralConvertible, ExtendedGraphemeClusterLiteralConvertible, _BuiltinStringLiteralConvertible, StringLiteralConvertible {
  var start: RawPointer
  var byteSize: Word
  var isASCII: Int1
  init()
  init(start: RawPointer, byteSize: Word, isASCII: Int1)
  static func _convertFromBuiltinExtendedGraphemeClusterLiteral(start: RawPointer, byteSize: Word, isASCII: Int1) -> StaticString
  static func convertFromExtendedGraphemeClusterLiteral(value: StaticString) -> StaticString
  static func _convertFromBuiltinStringLiteral(start: RawPointer, byteSize: Word, isASCII: Int1) -> StaticString
  static func convertFromStringLiteral(value: StaticString) -> StaticString
}

Streamable

1
2
3
protocol Streamable {
  func writeTo<Target : OutputStream>(inout target: Target)
}

StridedRangeGenerator

1
2
3
4
5
6
7
8
9
struct StridedRangeGenerator<T : ForwardIndex> : Generator, Sequence {
  typealias Element = T
  @transparent init(_ bounds: Range<T>, stride: T.DistanceType)
  func next() -> T?
  typealias GeneratorType = StridedRangeGenerator<T>
  func generate() -> StridedRangeGenerator<T>
  var _bounds: Range<T>
  var _stride: T.DistanceType
}

String

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
struct String {
  init()
  init(_ _core: _StringCore)
  var core: _StringCore
}
extension String {
  static func fromCString(cs: CString) -> String
  static func fromCString(up: UnsafePointer<CChar>) -> String
}
extension String {
  init(_ c: Character)
}
extension String : ExtensibleCollection {
  func reserveCapacity(n: Int)
  func extend<S : Sequence where Character == Character>(seq: S)
}
extension String {
  func withCString<Result>(f: (CString) -> Result) -> Result
  func withCString<Result>(f: (UnsafePointer<CChar>) -> Result) -> Result
}
extension String : Reflectable {
  func getMirror() -> Mirror
}
extension String : OutputStream {
  func write(string: String)
}
extension String : Streamable {
  func writeTo<Target : OutputStream>(inout target: Target)
}
extension String : _BuiltinExtendedGraphemeClusterLiteralConvertible {
  static func _convertFromBuiltinExtendedGraphemeClusterLiteral(start: RawPointer, byteSize: Word, isASCII: Int1) -> String
}
extension String : ExtendedGraphemeClusterLiteralConvertible {
  static func convertFromExtendedGraphemeClusterLiteral(value: String) -> String
}
extension String : _BuiltinUTF16StringLiteralConvertible {
  static func _convertFromBuiltinUTF16StringLiteral(start: RawPointer, numberOfCodeUnits: Word) -> String
}
extension String : _BuiltinStringLiteralConvertible {
  static func _convertFromBuiltinStringLiteral(start: RawPointer, byteSize: Word, isASCII: Int1) -> String
}
extension String : StringLiteralConvertible {
  static func convertFromStringLiteral(value: String) -> String
}
extension String : DebugPrintable {
  var debugDescription: String {
    get {}
  }
}
extension String {
  func _encodedLength<Encoding : UnicodeCodec>(encoding: Encoding.Type) -> Int
  func _encode<Encoding : UnicodeCodec, Output : Sink where Encoding.CodeUnit == Encoding.CodeUnit>(encoding: Encoding.Type, output: Output)
}
extension String : Equatable {
}
extension String {
  func _append(rhs: String)
  func _append(x: UnicodeScalar)
  var _utf16Count: Int {
    get {}
  }
  init(_ storage: _StringBuffer)
}
extension String : Hashable {
  var hashValue: Int {
    get {}
  }
}
extension String : StringInterpolationConvertible {
  static func convertFromStringInterpolation(strings: String...) -> String
  static func convertFromStringInterpolationSegment<T>(expr: T) -> String
}
extension String : Comparable {
}
extension String {
  @asmname("swift_stringFromUTF8InRawMemory") static func _fromUTF8InRawMemory(resultStorage: UnsafePointer<String>, start: UnsafePointer<CodeUnit>, utf8Count: Int)
}
extension String : Collection {
  struct Index : BidirectionalIndex {
    init(_ _base: String.UnicodeScalarView.IndexType)
    func succ() -> String.Index
    func pred() -> String.Index
    let _base: String.UnicodeScalarView.IndexType
    var _utf16Index: Int {
      get {}
    }
  }
  var startIndex: String.Index {
    get {}
  }
  var endIndex: String.Index {
    get {}
  }
  subscript (i: String.Index) -> Character {
    get {}
  }
  func generate() -> IndexingGenerator<String>
}
extension String : Sliceable {
  subscript (subRange: Range<String.Index>) -> String {
    get {}
  }
}
extension String {
  func join<S : Sequence where String == String>(elements: S) -> String
}
extension String {
  init<Encoding : UnicodeCodec, Input : Collection where Encoding.CodeUnit == Encoding.CodeUnit>(_ _encoding: Encoding.Type, input: Input)
  init(count sz: Int, repeatedValue c: Character)
  init(count: Int, repeatedValue c: UnicodeScalar)
  var _lines: String[] {
    get {}
  }
  func _split(separator: UnicodeScalar) -> String[]
  var isEmpty: Bool {
    get {}
  }
}
extension String {
  var uppercaseString: String {
    get {}
  }
  var lowercaseString: String {
    get {}
  }
  init(_ _c: UnicodeScalar)
  func _isAll(predicate: (UnicodeScalar) -> Bool) -> Bool
  func hasPrefix(prefix: String) -> Bool
  func hasSuffix(suffix: String) -> Bool
  func _isAlpha() -> Bool
  func _isDigit() -> Bool
  func _isSpace() -> Bool
}
extension String {
  init(_ v: Int64, radix: Int = default, _uppercase: Bool = default)
  init(_ v: UInt64, radix: Int = default, _uppercase: Bool = default)
  init(_ v: Int8, radix: Int = default, _uppercase: Bool = default)
  init(_ v: Int16, radix: Int = default, _uppercase: Bool = default)
  init(_ v: Int32, radix: Int = default, _uppercase: Bool = default)
  init(_ v: Int, radix: Int = default, _uppercase: Bool = default)
  init(_ v: UInt8, radix: Int = default, _uppercase: Bool = default)
  init(_ v: UInt16, radix: Int = default, _uppercase: Bool = default)
  init(_ v: UInt32, radix: Int = default, _uppercase: Bool = default)
  init(_ v: UInt, radix: Int = default, _uppercase: Bool = default)
  typealias _Double = Double
  typealias _Float = Float
  typealias _Bool = Bool
  init(_ v: _Double)
  init(_ v: _Float)
  init(_ b: _Bool)
}
extension String {
  func toInt() -> Int?
}
extension String {
  func _substr(start: Int) -> String
  func _splitFirst(delim: UnicodeScalar) -> (before: String, after: String, wasFound: Bool)
  func _splitFirstIf(pred: (UnicodeScalar) -> Bool) -> (before: String, found: UnicodeScalar, after: String, wasFound: Bool)
  func _splitIf(pred: (UnicodeScalar) -> Bool) -> String[]
}
extension String {
  struct UTF16View : Sliceable {
    var startIndex: Int {
      get {}
    }
    var endIndex: Int {
      get {}
    }
    typealias _GeneratorType = IndexingGenerator<_StringCore>
    typealias GeneratorType = _GeneratorType
    func generate() -> GeneratorType
    subscript (i: Int) -> CodeUnit {
      get {}
    }
    subscript (subRange: Range<Int>) -> String.UTF16View {
      get {}
    }
    init(_ _core: _StringCore)
    let _core: _StringCore
  }
  var utf16: String.UTF16View {
    get {}
  }
}
extension String {
  struct UTF8View : Collection {
    let _core: _StringCore
    init(_ _core: _StringCore)
    struct Index : ForwardIndex {
      init(_ _core: _StringCore, _ _coreIndex: Int, _ _buffer: UTF8Chunk)
      func succ() -> String.UTF8View.Index
      let _core: _StringCore
      let _coreIndex: Int
      let _buffer: UTF8Chunk
    }
    var startIndex: String.UTF8View.Index {
      get {}
    }
    var endIndex: String.UTF8View.Index {
      get {}
    }
    subscript (i: String.UTF8View.Index) -> CodeUnit {
      get {}
    }
    func generate() -> IndexingGenerator<String.UTF8View>
  }
  var utf8: String.UTF8View {
    get {}
  }
  var _contiguousUTF8: UnsafePointer<CodeUnit> {
    get {}
  }
  var nulTerminatedUTF8: ContiguousArray<CodeUnit> {
    get {}
  }
}
extension String {
  struct UnicodeScalarView : Sliceable, Sequence {
    init(_ _base: _StringCore)
    struct ScratchGenerator : Generator {
      var base: _StringCore
      var idx: Int
      init(_ core: _StringCore, _ pos: Int)
      func next() -> CodeUnit?
    }
    struct IndexType : BidirectionalIndex {
      init(_ _position: Int, _ _base: _StringCore)
      func succ() -> String.UnicodeScalarView.IndexType
      func pred() -> String.UnicodeScalarView.IndexType
      var _position: Int
      var _base: _StringCore
    }
    var startIndex: String.UnicodeScalarView.IndexType {
      get {}
    }
    var endIndex: String.UnicodeScalarView.IndexType {
      get {}
    }
    subscript (i: String.UnicodeScalarView.IndexType) -> UnicodeScalar {
      get {}
    }
    func __slice__(start: String.UnicodeScalarView.IndexType, end: String.UnicodeScalarView.IndexType) -> String.UnicodeScalarView
    subscript (r: Range<String.UnicodeScalarView.IndexType>) -> String.UnicodeScalarView {
      get {}
    }
    struct GeneratorType : Generator {
      init(_ _base: IndexingGenerator<_StringCore>)
      func next() -> UnicodeScalar?
      var _base: IndexingGenerator<_StringCore>
    }
    func generate() -> String.UnicodeScalarView.GeneratorType
    @conversion func __conversion() -> String
    func compare(other: String.UnicodeScalarView) -> Int
    func _compareUnicode(other: String.UnicodeScalarView) -> Int
    var _base: _StringCore
  }
}
extension String {
  func compare(other: String) -> Int
  var unicodeScalars: String.UnicodeScalarView {
    get {}
  }
}

StringElement

1
2
3
4
protocol StringElement {
  class func toUTF16CodeUnit(_: Self) -> CodeUnit
  class func fromUTF16CodeUnit(utf16: CodeUnit) -> Self
}

StringInterpolationConvertible

1
2
3
4
protocol StringInterpolationConvertible {
  class func convertFromStringInterpolation(strings: Self...) -> Self
  class func convertFromStringInterpolationSegment<T>(expr: T) -> Self
}

StringLiteralConvertible

1
2
3
4
protocol StringLiteralConvertible : ExtendedGraphemeClusterLiteralConvertible {
  typealias StringLiteralType : _BuiltinStringLiteralConvertible
  class func convertFromStringLiteral(value: StringLiteralType) -> Self
}

StringLiteralType

1
typealias StringLiteralType = String

UInt

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
struct UInt : UnsignedInteger {
  var value: Word
  @transparent init()
  @transparent init(_ v: Word)
  @transparent init(_ value: UInt)
  @transparent static func _convertFromBuiltinIntegerLiteral(value: Int2048) -> UInt
  @transparent static func convertFromIntegerLiteral(value: UInt) -> UInt
  @transparent func _getBuiltinArrayBoundValue() -> Word
  typealias ArrayBoundType = UInt
  func getArrayBoundValue() -> UInt
  static var max: UInt {
    @transparent get {}
  }
  static var min: UInt {
    @transparent get {}
  }
}
extension UInt : Printable {
  var description: String {
    get {}
  }
}
extension UInt : Hashable {
  var hashValue: Int {
    get {}
  }
}
extension UInt : RandomAccessIndex {
  @transparent func succ() -> UInt
  @transparent func pred() -> UInt
  @transparent func distanceTo(other: UInt) -> Int
  @transparent func advancedBy(amount: Int) -> UInt
  @transparent static func uncheckedAdd(lhs: UInt, _ rhs: UInt) -> (UInt, Bool)
  @transparent static func uncheckedSubtract(lhs: UInt, _ rhs: UInt) -> (UInt, Bool)
  @transparent static func uncheckedMultiply(lhs: UInt, _ rhs: UInt) -> (UInt, Bool)
  @transparent static func uncheckedDivide(lhs: UInt, _ rhs: UInt) -> (UInt, Bool)
  @transparent static func uncheckedModulus(lhs: UInt, _ rhs: UInt) -> (UInt, Bool)
  @transparent func toUIntMax() -> UIntMax
  @transparent func toIntMax() -> IntMax
  @transparent static func from(x: UIntMax) -> UInt
}
extension UInt : BitwiseOperations {
  static var allZeros: UInt {
    @transparent get {}
  }
}
extension UInt {
  @transparent init(_ v: UInt8)
  @transparent init(_ v: Int8)
  @transparent init(_ v: UInt16)
  @transparent init(_ v: Int16)
  @transparent init(_ v: UInt32)
  @transparent init(_ v: Int32)
  @transparent init(_ v: UInt64)
  @transparent init(_ v: Int64)
  @transparent init(_ v: Int)
  @transparent func asSigned() -> Int
}
extension UInt {
  @transparent init(_ v: Float)
  @transparent init(_ v: Double)
  @transparent init(_ v: Float80)
}
extension UInt : CVarArg {
  func encode() -> Word[]
}

UInt16

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
struct UInt16 : UnsignedInteger {
  var value: Int16
  @transparent init()
  @transparent init(_ v: Int16)
  @transparent init(_ value: UInt16)
  @transparent static func _convertFromBuiltinIntegerLiteral(value: Int2048) -> UInt16
  @transparent static func convertFromIntegerLiteral(value: UInt16) -> UInt16
  @transparent func _getBuiltinArrayBoundValue() -> Word
  typealias ArrayBoundType = UInt16
  func getArrayBoundValue() -> UInt16
  static var max: UInt16 {
    @transparent get {}
  }
  static var min: UInt16 {
    @transparent get {}
  }
}
extension UInt16 : Printable {
  var description: String {
    get {}
  }
}
extension UInt16 : Hashable {
  var hashValue: Int {
    get {}
  }
}
extension UInt16 : RandomAccessIndex {
  @transparent func succ() -> UInt16
  @transparent func pred() -> UInt16
  @transparent func distanceTo(other: UInt16) -> Int
  @transparent func advancedBy(amount: Int) -> UInt16
  @transparent static func uncheckedAdd(lhs: UInt16, _ rhs: UInt16) -> (UInt16, Bool)
  @transparent static func uncheckedSubtract(lhs: UInt16, _ rhs: UInt16) -> (UInt16, Bool)
  @transparent static func uncheckedMultiply(lhs: UInt16, _ rhs: UInt16) -> (UInt16, Bool)
  @transparent static func uncheckedDivide(lhs: UInt16, _ rhs: UInt16) -> (UInt16, Bool)
  @transparent static func uncheckedModulus(lhs: UInt16, _ rhs: UInt16) -> (UInt16, Bool)
  @transparent func toUIntMax() -> UIntMax
  @transparent func toIntMax() -> IntMax
  @transparent static func from(x: UIntMax) -> UInt16
}
extension UInt16 : BitwiseOperations {
  static var allZeros: UInt16 {
    @transparent get {}
  }
}
extension UInt16 {
  @transparent init(_ v: UInt8)
  @transparent init(_ v: Int8)
  @transparent init(_ v: Int16)
  @transparent init(_ v: UInt32)
  @transparent init(_ v: Int32)
  @transparent init(_ v: UInt64)
  @transparent init(_ v: Int64)
  @transparent init(_ v: UInt)
  @transparent init(_ v: Int)
  @transparent func asSigned() -> Int16
}
extension UInt16 {
  @transparent init(_ v: Float)
  @transparent init(_ v: Double)
  @transparent init(_ v: Float80)
}
extension UInt16 : Reflectable {
  func getMirror() -> Mirror
}
extension CodeUnit : StringElement {
  static func toUTF16CodeUnit(x: CodeUnit) -> CodeUnit
  static func fromUTF16CodeUnit(utf16: CodeUnit) -> CodeUnit
}
extension UInt16 : CVarArg {
  func encode() -> Word[]
}

UInt32

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
struct UInt32 : UnsignedInteger {
  var value: Int32
  @transparent init()
  @transparent init(_ v: Int32)
  @transparent init(_ value: UInt32)
  @transparent static func _convertFromBuiltinIntegerLiteral(value: Int2048) -> UInt32
  @transparent static func convertFromIntegerLiteral(value: UInt32) -> UInt32
  @transparent func _getBuiltinArrayBoundValue() -> Word
  typealias ArrayBoundType = UInt32
  func getArrayBoundValue() -> UInt32
  static var max: UInt32 {
    @transparent get {}
  }
  static var min: UInt32 {
    @transparent get {}
  }
}
extension UInt32 : Printable {
  var description: String {
    get {}
  }
}
extension UInt32 : Hashable {
  var hashValue: Int {
    get {}
  }
}
extension UInt32 : RandomAccessIndex {
  @transparent func succ() -> UInt32
  @transparent func pred() -> UInt32
  @transparent func distanceTo(other: UInt32) -> Int
  @transparent func advancedBy(amount: Int) -> UInt32
  @transparent static func uncheckedAdd(lhs: UInt32, _ rhs: UInt32) -> (UInt32, Bool)
  @transparent static func uncheckedSubtract(lhs: UInt32, _ rhs: UInt32) -> (UInt32, Bool)
  @transparent static func uncheckedMultiply(lhs: UInt32, _ rhs: UInt32) -> (UInt32, Bool)
  @transparent static func uncheckedDivide(lhs: UInt32, _ rhs: UInt32) -> (UInt32, Bool)
  @transparent static func uncheckedModulus(lhs: UInt32, _ rhs: UInt32) -> (UInt32, Bool)
  @transparent func toUIntMax() -> UIntMax
  @transparent func toIntMax() -> IntMax
  @transparent static func from(x: UIntMax) -> UInt32
}
extension UInt32 : BitwiseOperations {
  static var allZeros: UInt32 {
    @transparent get {}
  }
}
extension UInt32 {
  @transparent init(_ v: UInt8)
  @transparent init(_ v: Int8)
  @transparent init(_ v: UInt16)
  @transparent init(_ v: Int16)
  @transparent init(_ v: Int32)
  @transparent init(_ v: UInt64)
  @transparent init(_ v: Int64)
  @transparent init(_ v: UInt)
  @transparent init(_ v: Int)
  @transparent func asSigned() -> Int32
}
extension UInt32 {
  @transparent init(_ v: Float)
  @transparent init(_ v: Double)
  @transparent init(_ v: Float80)
}
extension UInt32 : Reflectable {
  func getMirror() -> Mirror
}
extension UInt32 {
  init(_ v: UnicodeScalar)
}
extension UInt32 : CVarArg {
  func encode() -> Word[]
}

UInt64

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
struct UInt64 : UnsignedInteger {
  var value: Int64
  @transparent init()
  @transparent init(_ v: Int64)
  @transparent init(_ value: UInt64)
  @transparent static func _convertFromBuiltinIntegerLiteral(value: Int2048) -> UInt64
  @transparent static func convertFromIntegerLiteral(value: UInt64) -> UInt64
  @transparent func _getBuiltinArrayBoundValue() -> Word
  typealias ArrayBoundType = UInt64
  func getArrayBoundValue() -> UInt64
  static var max: UInt64 {
    @transparent get {}
  }
  static var min: UInt64 {
    @transparent get {}
  }
}
extension UInt64 : Printable {
  var description: String {
    get {}
  }
}
extension UInt64 : Hashable {
  var hashValue: Int {
    get {}
  }
}
extension UInt64 : RandomAccessIndex {
  @transparent func succ() -> UInt64
  @transparent func pred() -> UInt64
  @transparent func distanceTo(other: UInt64) -> Int
  @transparent func advancedBy(amount: Int) -> UInt64
  @transparent static func uncheckedAdd(lhs: UInt64, _ rhs: UInt64) -> (UInt64, Bool)
  @transparent static func uncheckedSubtract(lhs: UInt64, _ rhs: UInt64) -> (UInt64, Bool)
  @transparent static func uncheckedMultiply(lhs: UInt64, _ rhs: UInt64) -> (UInt64, Bool)
  @transparent static func uncheckedDivide(lhs: UInt64, _ rhs: UInt64) -> (UInt64, Bool)
  @transparent static func uncheckedModulus(lhs: UInt64, _ rhs: UInt64) -> (UInt64, Bool)
  @transparent func toUIntMax() -> UIntMax
  @transparent func toIntMax() -> IntMax
  @transparent static func from(x: UIntMax) -> UInt64
}
extension UInt64 : BitwiseOperations {
  static var allZeros: UInt64 {
    @transparent get {}
  }
}
extension UInt64 {
  @transparent init(_ v: UInt8)
  @transparent init(_ v: Int8)
  @transparent init(_ v: UInt16)
  @transparent init(_ v: Int16)
  @transparent init(_ v: UInt32)
  @transparent init(_ v: Int32)
  @transparent init(_ v: Int64)
  @transparent init(_ v: UInt)
  @transparent init(_ v: Int)
  @transparent func asSigned() -> Int64
}
extension UInt64 {
  @transparent init(_ v: Float)
  @transparent init(_ v: Double)
  @transparent init(_ v: Float80)
}
extension UInt64 : Reflectable {
  func getMirror() -> Mirror
}
extension UInt64 {
  init(_ v: UnicodeScalar)
}
extension UInt64 : CVarArg {
  func encode() -> Word[]
}

UInt8

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
struct UInt8 : UnsignedInteger {
  var value: Int8
  @transparent init()
  @transparent init(_ v: Int8)
  @transparent init(_ value: UInt8)
  @transparent static func _convertFromBuiltinIntegerLiteral(value: Int2048) -> UInt8
  @transparent static func convertFromIntegerLiteral(value: UInt8) -> UInt8
  @transparent func _getBuiltinArrayBoundValue() -> Word
  typealias ArrayBoundType = UInt8
  func getArrayBoundValue() -> UInt8
  static var max: UInt8 {
    @transparent get {}
  }
  static var min: UInt8 {
    @transparent get {}
  }
}
extension UInt8 : Printable {
  var description: String {
    get {}
  }
}
extension UInt8 : Hashable {
  var hashValue: Int {
    get {}
  }
}
extension UInt8 : RandomAccessIndex {
  @transparent func succ() -> UInt8
  @transparent func pred() -> UInt8
  @transparent func distanceTo(other: UInt8) -> Int
  @transparent func advancedBy(amount: Int) -> UInt8
  @transparent static func uncheckedAdd(lhs: UInt8, _ rhs: UInt8) -> (UInt8, Bool)
  @transparent static func uncheckedSubtract(lhs: UInt8, _ rhs: UInt8) -> (UInt8, Bool)
  @transparent static func uncheckedMultiply(lhs: UInt8, _ rhs: UInt8) -> (UInt8, Bool)
  @transparent static func uncheckedDivide(lhs: UInt8, _ rhs: UInt8) -> (UInt8, Bool)
  @transparent static func uncheckedModulus(lhs: UInt8, _ rhs: UInt8) -> (UInt8, Bool)
  @transparent func toUIntMax() -> UIntMax
  @transparent func toIntMax() -> IntMax
  @transparent static func from(x: UIntMax) -> UInt8
}
extension UInt8 : BitwiseOperations {
  static var allZeros: UInt8 {
    @transparent get {}
  }
}
extension UInt8 {
  @transparent init(_ v: Int8)
  @transparent init(_ v: UInt16)
  @transparent init(_ v: Int16)
  @transparent init(_ v: UInt32)
  @transparent init(_ v: Int32)
  @transparent init(_ v: UInt64)
  @transparent init(_ v: Int64)
  @transparent init(_ v: UInt)
  @transparent init(_ v: Int)
  @transparent func asSigned() -> Int8
}
extension UInt8 {
  @transparent init(_ v: Float)
  @transparent init(_ v: Double)
  @transparent init(_ v: Float80)
}
extension UInt8 : Reflectable {
  func getMirror() -> Mirror
}
extension CodeUnit : StringElement {
  static func toUTF16CodeUnit(x: CodeUnit) -> CodeUnit
  static func fromUTF16CodeUnit(utf16: CodeUnit) -> CodeUnit
}
extension UInt8 {
  init(_ v: UnicodeScalar)
}
extension UInt8 : CVarArg {
  func encode() -> Word[]
}

UIntMax

1
typealias UIntMax = UInt64

UnicodeCodec

1
2
3
4
5
protocol UnicodeCodec {
  typealias CodeUnit
  class func decode<G : Generator where `Self`.CodeUnit == CodeUnit>(inout next: G) -> UnicodeScalar?
  class func encode<S : Sink where `Self`.CodeUnit == CodeUnit>(input: UnicodeScalar, inout output: S)
}

UnicodeScalar

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
struct UnicodeScalar : ExtendedGraphemeClusterLiteralConvertible {
  var _value: Int32
  var value: UInt32 {
    get {}
  }
  static func convertFromExtendedGraphemeClusterLiteral(value: String) -> UnicodeScalar
  init()
  init(_ value: Int32)
  init(_ v: UInt32)
  init(_ v: UnicodeScalar)
  func escape() -> String
  func isASCII() -> Bool
  func isAlpha() -> Bool
  func isDigit() -> Bool
  var uppercase: UnicodeScalar {
    get {}
  }
  var lowercase: UnicodeScalar {
    get {}
  }
  func isSpace() -> Bool
}
extension UnicodeScalar : Streamable {
  func writeTo<Target : OutputStream>(inout target: Target)
}
extension UnicodeScalar : Printable {
  var description: String {
    get {}
  }
}
extension UnicodeScalar : Hashable {
  var hashValue: Int {
    get {}
  }
}
extension UnicodeScalar {
  init(_ v: Int)
}
extension UnicodeScalar : Comparable {
}
extension UnicodeScalar {
  func isPrint() -> Bool
}

Unmanaged

1
2
3
4
5
6
7
8
9
10
11
12
13
struct Unmanaged<T> {
  var _value: @sil_unmanaged T
  @transparent init(_private: T)
  @transparent static func fromOpaque(value: COpaquePointer) -> Unmanaged<T>
  @transparent func toOpaque() -> COpaquePointer
  @transparent static func passRetained(value: T) -> Unmanaged<T>
  @transparent static func passUnretained(value: T) -> Unmanaged<T>
  func takeUnretainedValue() -> T
  func takeRetainedValue() -> T
  @transparent func retain() -> Unmanaged<T>
  @transparent func release()
  @transparent func autorelease() -> Unmanaged<T>
}

UnsafeArray

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
struct UnsafeArray<T> : Collection, Generator {
  var startIndex: Int {
    get {}
  }
  var endIndex: Int {
    get {}
  }
  subscript (i: Int) -> T {
    get {}
  }
  init(start: UnsafePointer<T>, length: Int)
  func next() -> T?
  func generate() -> UnsafeArray<T>
  var _position: UnsafePointer<T>
  var _end: UnsafePointer<T>
}

UnsafePointer

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
struct UnsafePointer<T> : BidirectionalIndex, Comparable, Hashable, LogicValue {
  var value: RawPointer
  init()
  init(_ value: RawPointer)
  init(_ other: COpaquePointer)
  init(_ value: Int)
  init<U>(_ from: UnsafePointer<U>)
  static func null() -> UnsafePointer<T>
  static func alloc(num: Int) -> UnsafePointer<T>
  func dealloc(num: Int)
  var memory: T {
    @transparent get {}
    @transparent set {}
  }
  func initialize(newvalue: T)
  func move() -> T
  func moveInitializeBackwardFrom(source: UnsafePointer<T>, count: Int)
  func moveAssignFrom(source: UnsafePointer<T>, count: Int)
  func moveInitializeFrom(source: UnsafePointer<T>, count: Int)
  func initializeFrom(source: UnsafePointer<T>, count: Int)
  func initializeFrom<C : Collection where T == T>(source: C)
  func destroy()
  func destroy(count: Int)
  var _isNull: Bool {
    @transparent get {}
  }
  @transparent func getLogicValue() -> Bool
  subscript (i: Int) -> T {
    @transparent get {}
    @transparent set {}
  }
  var hashValue: Int {
    get {}
  }
  func succ() -> UnsafePointer<T>
  func pred() -> UnsafePointer<T>
  @conversion @transparent func __conversion() -> CMutablePointer<T>
  func __conversion() -> CMutableVoidPointer
  @conversion @transparent func __conversion() -> CConstPointer<T>
  @conversion @transparent func __conversion() -> CConstVoidPointer
  @conversion @transparent func __conversion() -> AutoreleasingUnsafePointer<T>
  init(_ cp: CConstPointer<T>)
  init(_ cm: CMutablePointer<T>)
  init(_ op: AutoreleasingUnsafePointer<T>)
  init(_ cp: CConstVoidPointer)
  init(_ cp: CMutableVoidPointer)
}
extension UnsafePointer<T> : Printable {
  var description: String {
    get {}
  }
}

UnsignedInteger

1
protocol UnsignedInteger : _UnsignedInteger, Integer {}

UTF16

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
struct UTF16 : UnicodeCodec {
  typealias CodeUnit = UInt16
  static func decode<G : Generator where CodeUnit == CodeUnit>(inout input: G) -> UnicodeScalar?
  static func encode<S : Sink where CodeUnit == CodeUnit>(input: UnicodeScalar, inout output: S)
  var _value
  init(_value: UInt16)
  init()
}
extension UTF16 {
  static func width(x: UnicodeScalar) -> Int
  static func leadSurrogate(x: UnicodeScalar) -> CodeUnit
  static func trailSurrogate(x: UnicodeScalar) -> CodeUnit
  static func copy<T : StringElement, U : StringElement>(source: UnsafePointer<T>, destination: UnsafePointer<U>, count: Int)
  static func measure<Encoding : UnicodeCodec, Input : Generator where Encoding.CodeUnit == Encoding.CodeUnit>(_: Encoding.Type, input: Input) -> (Int, Bool)
}

UTF32

1
2
3
4
5
6
7
8
9
struct UTF32 : UnicodeCodec {
  typealias CodeUnit = UInt32
  init(_ _value: UInt32)
  static func create(value: CodeUnit) -> UTF32
  func value() -> CodeUnit
  static func decode<G : Generator where CodeUnit == CodeUnit>(inout input: G) -> UnicodeScalar?
  static func encode<S : Sink where CodeUnit == CodeUnit>(input: UnicodeScalar, inout output: S)
  var _value
}

UTF8

1
2
3
4
5
6
7
8
struct UTF8 : UnicodeCodec {
  typealias CodeUnit = UInt8
  static func decode<G : Generator where CodeUnit == CodeUnit>(inout next: G) -> UnicodeScalar?
  static func encode<S : Sink where CodeUnit == CodeUnit>(input: UnicodeScalar, inout output: S)
  var _value
  init(_value: UInt8)
  init()
}

UWord

1
typealias UWord = UInt

VaListBuilder

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
@final class VaListBuilder {
  struct Header {
    var gp_offset
    var fp_offset
    var overflow_arg_area: UnsafePointer<Word>
    var reg_save_area: UnsafePointer<Word>
    init(gp_offset: UInt32, fp_offset: UInt32, overflow_arg_area: UnsafePointer<Word>, reg_save_area: UnsafePointer<Word>)
    init()
  }
  init()
  @final @final func append(arg: CVarArg)
  @final @final func va_list() -> CVaListPointer
  var gpRegistersUsed
  var sseRegistersUsed
  var header
  var storage: Word[]
  @objc deinit
}

Void

1
typealias Void = ()

Word

1
typealias Word = Int

Zip2

1
2
3
4
5
6
7
8
struct Zip2<S0 : Sequence, S1 : Sequence> : Sequence {
  typealias Stream1 = S0.GeneratorType
  typealias Stream2 = S1.GeneratorType
  typealias GeneratorType = ZipGenerator2<S0.GeneratorType, S1.GeneratorType>
  init(_ s0: S0, _ s1: S1)
  func generate() -> GeneratorType
  var sequences: (S0, S1)
}

ZipGenerator2

1
2
3
4
5
6
struct ZipGenerator2<E0 : Generator, E1 : Generator> : Generator {
  typealias Element = (E0.Element, E1.Element)
  init(_ e0: E0, _ e1: E1)
  func next() -> Element?
  var baseStreams: (E0, E1)
}

C_ARGC: CInt

C_ARGV: UnsafePointer<CString>

__COLUMN__: Int

Current column.

__FILE__: String

Current file name.

__LINE__: Int

Current line.

Swift Standard Library (Swift 标准库)

所有默认函数在 Swift 名字空间,即 Swift.abs 这样。

所有的函数功能都是我猜的。猜错别找我。

第一部分 a to z

abs

1
abs(x: T) -> T

绝对值, 所有数字类型均可。

abs(-20.3)

advance

1
2
advance(start: T, n: T.DistanceType) -> T
advance(start: T, n: T.DistanceType, end: T) -> T

计算步进和距离的函数貌似。

advance(0, 20) // 20
advance(2, 20, 4) // 4

alignof alignofValue

1
2
alignof(T.Type) -> Int
alignofValue(T) -> Int    

计算类型的 alignment。

1
2
3
alignof(Int)
alignof(Uint8)
alignofValue(Float(3.2))    

assert

1
2
assert(condition: @auto_closure () -> Bool, message: StaticString, file: StaticString, line: UWord) -> Void
assert(condition: @auto_closure () -> T, message: StaticString, file: StaticString, line: UWord) -> Void

断言语句。因为是 @auto_closure, 所以直接写语句就可以了,第二个 T 的限制是 LogicValue, 所以 Optional 也可以。

1
2
3
4
let age = 17
assert(age > 0, "Alive Only")
assert(age > 18, "Adult Only", file: __FILE__, line: __LINE__)
assert("342345".toInt())

bridge*

1
2
3
4
bridgeFromObjectiveC(x: AnyObject, T.Type) -> T?
bridgeFromObjectiveCUnconditional(x: AnyObject, T.Type) -> T
bridgeToObjectiveC(x: T) -> AnyObject?
bridgeToObjectiveCUnconditional(x: T) -> AnyObject

c_malloc_size

c_malloc_size(heapMemory: UnsafePointer<Void>) -> Int

c_memcpy

c_memcpy(dest: UnsafePointer<Void>, src: UnsafePointer<Void>, size: UInt) -> Void

c_putchar(value: Int32) -> Void

c_putchar(value: Int32) -> Void

就是 putchar,最基础的 output 语句。

c_putchar(97) // ASCII 'a'

contains

1
2
contains(seq: S, predicate: (S.GeneratorType.Element) -> L) -> Bool
contains(seq: S, x: S.GeneratorType.Element) -> Bool

判断序列是否包含某元素、是否包含满足某条件的元素。

1
2
3
let a = [1,2,4,56,7]
contains(a, { $0 > 50 }) // true
contains(a, 56)

count countElements

1
2
count(r: Range<I>) -> I.DistanceType
countElements(x: T) -> T.IndexType.DistanceType

数元素、Range 个数。

1
2
3
count(1..20)
let a = [1,2,4,56,7]
countElements(a) // 5

countLeadingZeros

countLeadingZeros(value: Int64) -> Int64

Count Leading Zeros in Binary Format. 二进制格式前面有多少个 0.

1
2
countLeadingZeros(1) // 63
countLeadingZeros(-1) // 0

debugPrint debugPrintln

1
2
3
4
debugPrint(object: T) -> Void
debugPrint(object: T, &target: TargetStream) -> Void
debugPrintln(object: T) -> Void
debugPrintln(object: T, &target: TargetStream) -> Void

打印任意对象。TargetStream 暂时未知。

distance

distance(start: T, end: T) -> T.DistanceType

起止距离.

distance(1, 20) // 19

dropFirst dropLast

1
2
dropFirst(seq: Seq) -> Seq.SliceType
dropLast(seq: Seq) -> Seq.SliceType

序列操作函数。

1
2
3
4
5
6
let b = [1,2,3,4,5]
// b : Array<Int> = [1, 2, 3, 4, 5]
dropFirst(b)
// r16 : Slice<Int> = [2, 3, 4, 5]
dropLast(b)
// r17 : Slice<Int> = [1, 2, 3, 4]

dump

1
2
dump(x: T, name: String?, indent: Int, maxDepth: Int, maxItems: Int) -> T
dump(x: T, name: String?, indent: Int, maxDepth: Int, maxItems: Int, &targetStream: TargetStream) -> T

打印变量的详情。

1
2
3
4
let b = [1,2,3,4,5]
dump(b) // detailed output at console
dump(b, name: "A Array B")
dump("Hello World")

encodeBitsAsWords

encodeBitsAsWords(x: T) -> Word[]

未知作用。尝试发现类型是 ASCII 码。

encodeBitsAsWords(97) // [97]: Word[]

enumerate

enumerate(seq: Seq) -> EnumerateGenerator<Seq.GeneratorType>

同 Python enumerate.

1
2
let b = [1,2,3,4,5]
for (idx, val) in enumerate(b) { println("b \(idx) = \(val)") }

equal

1
2
equal(a1: S1, a2: S2) -> Bool
equal(a1: S1, a2: S2, pred: (S1.GeneratorType.Element, S1.GeneratorType.Element) -> Bool) -> Bool

比较相等。

1
2
equal(2, 1+1)
equal([1,2,3,4], [2,4,6,8], { $0 * 2 == $1 })

fatalError

fatalError(message: StaticString, file: StaticString, line: UWord) -> Void

Runtime fatal error. then quit.

fatalError("Taylor Swift Sucks")

filter

1
2
filter(source: C, includeElement: (C.GeneratorType.Element) -> Bool) -> FilterCollectionView<C>
filter(source: S, includeElement: (S.GeneratorType.Element) -> Bool) -> FilterSequenceView<S>

同 Python filter。

1
2
3
let b = [1,2,3,4,5]
for i in filter(b, { $0 > 3 }) { println("got \(i)") }
for i in filter(1...100, { $0 % 17 == 0 }) { println("got \(i)") }

find

find(domain: C, value: C.GeneratorType.Element) -> C.IndexType?

查找某一元素的索引值。

1
2
3
let b = [1,2,3,4,5]
find(b, 20) // nil
find(b, 2)  // 1

getBridgedObjectiveCType

getBridgedObjectiveCType(T.Type) -> Any.Type?

getVaList

getVaList(args: CVarArg[]) -> CVaListPointer

indices

indices(seq: Seq) -> Range<Seq.IndexType>

索引的迭代器。

1
2
3
let b = [1,2,3,4,5]
for i in indices(b) { println(i) }
// 0 1 2 3 4

insertionSort

1
2
insertionSort(&elements: C, range: Range<C.IndexType>) -> Void
insertionSort(&elements: C, range: Range<C.IndexType>, &less: (C.GeneratorType.Element, C.GeneratorType.Element) -> Bool) -> Void

插入排序。range 表示排序范围。

1
2
3
var tt = [23, 34, 56, 45, 67, 12, 78, 89, 90]
insertionSort(&tt, 0..5)
println(tt)

isBridgedToObjectiveC isBridgedVerbatimToObjectiveC

1
2
isBridgedToObjectiveC(T.Type) -> Bool
isBridgedVerbatimToObjectiveC(T.Type) -> Bool

isUniquelyReferenced

isUniquelyReferenced(&x: T) -> Bool    

join

func join<C : ExtensibleCollection, S : Sequence where C == C>(separator: C, elements: S) -> C

序列的 join 操作

join("!!", ["Hello", "World"])

lexicographicalCompare

1
2
lexicographicalCompare(a1: S1, a2: S2) -> Bool
lexicographicalCompare(a1: S1, a2: S2, less: (S1.GeneratorType.Element, S1.GeneratorType.Element) -> Bool) -> Bool

map

1
2
3
map(source: C, transform: (C.GeneratorType.Element) -> T) -> MapCollectionView<C, T>
map(source: S, transform: (S.GeneratorType.Element) -> T) -> MapSequenceView<S, T>
map(x: T?, f: (T) -> U) -> U?

同 Python map 操作。

1
2
3
for i in map([1,2,3,4], { $0 * 10 }) { println(i) }
let optVal: Int? = 250
let v: Int? =  map(optVal, { $0 + 1 }) // 251

max maxElement

1
2
max(x: T, y: T, rest: T[]) -> T
maxElement(range: R) -> R.GeneratorType.Element

最大值。

1
2
3
max(2, 4)
max(1,2,4,5,6,100,4,5,6,7) // 100
maxElement([1,2,4,5,6,100,4,5,6,7])

min minElement

1
2
min(x: T, y: T, rest: T[]) -> T
minElement(range: R) -> R.GeneratorType.Element

最小值。Same usage as max

numericCast

numericCast(x: T) -> U

Cast between unsigned and signed integers.

1
2
let bb: UInt8 = 20
let cc: Int = numericCast(bb)

partition

1
2
partition(&elements: C, range: Range<C.IndexType>) -> C.IndexType
partition(&elements: C, range: Range<C.IndexType>, &less: (C.GeneratorType.Element, C.GeneratorType.Element) -> Bool) -> C.IndexType

Unknown usage.

1
2
var tt = [12, 23, 34, 45, 56, 67, 78, 89, 90]
println(partition(&tt, 3..4))

posix_read posix_write

1
2
posix_read(fd: Int32, buf: RawPointer, sz: Int) -> Int
posix_write(fd: Int32, buf: RawPointer, sz: Int) -> Int

print println

1
2
3
4
5
print(object: T) -> Void
print(object: T, &target: TargetStream) -> Void
println() -> Void
println(object: T) -> Void
println(object: T, &target: TargetStream) -> Void

打印语句,们。

quickSort

1
2
quickSort(&elements: C, range: Range<C.IndexType>) -> Void
quickSort(&elements: C, range: Range<C.IndexType>, less: (C.GeneratorType.Element, C.GeneratorType.Element) -> Bool) -> Void

快排序, range表示需要排序的范围。

1
2
3
var tt = [23, 34, 56, 45, 67, 12, 78, 89, 90]
quickSort(&tt, 0..5)
quickSort(&tt, 0..5, { $1 < $0 }) // 逆序

reduce

reduce(sequence: S, initial: U, combine: (U, S.GeneratorType.Element) -> U) -> U

同 Python 中 reduce, 类似 Haskell fold 系列函数。

1
2
3
// reduce 应用之 求和
let tt = [23, 34, 56, 45, 67, 12, 78, 89, 90]
reduce(tt, 0, { $0 + $1 })

reflect

reflect(x: T) -> Mirror

暂时未知

reinterpretCast

reinterpretCast(x: T) -> U

相同 size 的类型,之间的直接 cast.

1
2
3
4
let a: Int = -1
let c: UInt = reinterpretCast(a)
println(c)
println(UInt.max) // 一定等于 c 。别问我为什么。

reverse

reverse(source: C) -> ReverseView<C>

同 Python reversed(),逆序的迭代器。

1
2
let tt = [23, 34, 56, 45, 67, 12, 78, 89, 90]
for i in reverse(tt) { println(i) }

roundUpToAlignment

roundUpToAlignment(offset: Int, alignment: Int) -> Int

内存 alignment 计算函数。比如 alignment 为 4 字节,offset 为 5, 那么将在下个 4 字节, 即 8 的位置上对齐。

1
2
roundUpToAlignment(2, 4) // 4
roundUpToAlignment(5, 4) // 8

sizeof sizeofValue

1
2
sizeof(T.Type) -> Int
sizeofValue(T) -> Int

计算类型或者值的 size。

1
2
sizeof(Int)
sizeofValue(2.4)  // a Double

sort

1
2
sort(array: T[]) -> T[]
sort(array: T[], pred: (T, T) -> Bool) -> T[]

排序函数。类似 Python sorted()。

1
2
3
let foo = [18, 14, 21, 8, 45, 12, 9]
sort(foo)
sort(foo, { String($0) < String($1) }) // 按照 ASCII 顺序排序

split

split(seq: Seq, isSeparator: (Seq.GeneratorType.Element) -> R, maxSplit: Int, allowEmptySlices: Bool) -> Seq.SliceType[]

分割序列函数。

1
2
split("Hello World", { $0 == " " })
// : String[] = ["Hello", "World"]

startsWith

startsWith(s0: S0, s1: S1) -> Bool

判断序列开头子序列。

1
2
startsWith(1..100, 1..2)
startsWith("Hello World", "Hel")

strideof strideofValue

1
2
strideof(T.Type) -> Int
strideofValue(T) -> Int

计算内存 stride 。用法同 sizeof sizeofValue。

swap

swap(&a: T, &b: T) -> Void

交换值。

1
2
var a = 1, b = 2
swap(&a, &b)

swift_*

1
2
3
swift_bufferAllocate(bufferType: HeapBufferStorageBase.Type, size: Int, alignMask: Int) -> AnyObject
swift_keepAlive(&T) -> Void
swift_MagicMirrorData_summaryImpl(metadata: Any.Type, result: UnsafePointer<String>) -> Void

toString

toString(object: T) -> String

这个没啥好说的。就是 toString。例子我都懒得举。

transcode

1
2
transcode(inputEncoding: Encoding.Type, outputEncoding: Encoding.Type, input: Input, output: Output) -> Void
transcode(inputEncoding: InputEncoding.Type, outputEncoding: OutputEncoding.Type, input: Input, output: Output) -> Void

未知。

underestimateCount

underestimateCount(x: T) -> Int

预估 Sequence 的成员个数。

1
underestimateCount(1..1000)

unsafeReflect

unsafeReflect(owner: NativeObject, ptr: UnsafePointer<T>) -> Mirror

未知。

withExtendedLifetime

withExtendedLifetime(x: T, f: (T) -> Result) -> Result

withObjectAtPlusZero

withObjectAtPlusZero(x: AnyObject, f: (COpaquePointer) -> Result) -> Result

withUnsafePointer withUnsafePointers withUnsafePointerToObject

1
2
3
4
withUnsafePointer(&arg: T, body: (UnsafePointer<T>) -> Result) -> Result
withUnsafePointers(&arg0: A0, &arg1: A1, &arg2: A2, body: (UnsafePointer<A0>, UnsafePointer<A1>, UnsafePointer<A2>) -> Result) -> Result
withUnsafePointers(&arg0: A0, &arg1: A1, body: (UnsafePointer<A0>, UnsafePointer<A1>) -> Result) -> Result
withUnsafePointerToObject(&arg: T?, body: (UnsafePointer<ImplicitlyUnwrappedOptional<T>>) -> Result) -> Result

来自 Rust 的同学对这里一定不会太陌生。不过作用和使用场合未知。

withVaList

1
2
withVaList(args: CVarArg[], f: (CVaListPointer) -> R) -> R
withVaList(builder: VaListBuilder, f: (CVaListPointer) -> R) -> R

Swift 运算符重载、自定义运算符

挖坑先。其实是ibooks书最后的参考手册部分。 这里将手册相关内容都搬运了过来。:)

Swift 对运算符重载的控制很类似 Haskell,而不是 C 系列。如下:

  • 支持自定义运算符 / = - + * % < > ! & | ^ . ~ 的任意组合。可以脑洞大开创造颜文字。
  • 支持前缀(例如默认的 ~,!,++, -- ),后缀(后置的 ++, --),中缀(* / 等等)运算符。
  • 支持自定义优先级。

运算符重载通过函数定义来完成,其实运算符就是一个一元函数,或者是二元函数。

所以那个传的很神的例子 numbers.sort(<) 不算什么,说到底就是个比较函数而已。(来自Haskell的同学基本可以忽略这些内容了,这些太熟悉了)

关键字

首先介绍用到的关键字,不得不说,Swift的关键字和Swift前男友一样多。

  • operator
  • prefix 前缀运算符,比如 (取正+、取负- 、自增++、自减–)
  • postfix 后缀运算符,比如(自增++、自减–),这两可以前缀也可以后缀
  • infix 中缀,最常见二元运算
  • precedence 优先级的意思,取值 0~255 ,纯数字,不可以带符号,下划线,指数e/p 表示
  • associativity 结合性,可以是 left, right, 或者 none

还有用到的属性,就是以 @ 开头的,这个理论上不算是关键字啊。别叫错了。(不过其实无所谓怎么叫,圈里有太多太多的人纠结于简单的定义为一个定义的名字争面红耳赤其实都说的一个意思。名字真的是很次要的东西,用英语吧)

  • @prefix
  • @postfix
  • @infix
  • @assignment 表示运算符具有“赋值”副作用,比如 ++, += 这样。

先来个最简单的,假设我们有

struct Point {
    var x: Int
    var y: Int
}
let p = Point(x: 100, y: 200)

前缀运算符

来个不靠谱的,假设我要执行 -p 这个操作。由于 “-” 已经是定义好了的运算符(减法),直接实现运算即可:

@prefix func - (pt: Point) -> Point {
    return Point(x: -pt.x, y: -pt.y)
}
println(-p) // 看起来高大上

@prefix 属性表示这个 - 运算作为前缀运算符处理,相当于取负。

中缀运算符

这么一来,接下来的需求就是两个点之和,“+“ 加法。同理 “+“已经定义,不需要再次定义。直接实现它

@infix func + (pt0: Point, pt1: Point) -> Point {
    return Point(x: pt0.x + pt1.x, y: pt0.y + pt1.y)
}

可以在 Playground 里输入 p + p 看看结果。

有了 p + p,直接实现乘法是不是更好呢?乘以一个 Int。这里 “*” 操作的两边就不是同个类型了。需要注意。

@infix func * (pt: Point, scale: Int) -> Point {
    return Point(x: pt.x * scale, y: pt.y * scale )
}

输入 p * 3 查看效果,然后输入 3 * p 发现出错,所以运算符左右两边的顺序是很重要的。(来自Python的同学可能会知道 Py 的运算符重载的左右类型是有一个尝试顺序的, __mul__, __rmul__ 等等)

后缀运算符

假设,我们的应用里,需要经常计算点到原点(0,0) 的距离,我们“发明”个新运算好了,我们就选一个 “~!", 来个后缀的,期望 "p~!” 取得点到原点的距离。

operator postfix ~! {} // 定义新运算符
@postfix func ~! (pt: Point) -> Double {
    return sqrt(NSNumber.convertFromIntegerLiteral(pt.x * pt.x + pt.y * pt.y).doubleValue)
}

平方根算得略纠结。。。忽略好了。反正暂时这么可以调用。 然后输入 p~! 获得距离。

自定义中缀运算符

前面基本已经介绍了怎么重载运算符,怎么实现。以及简单介绍了后缀运算符的自定义。

实际上中缀运算符(二元运算)牵扯到的优先级和结合性问题还是挺纠结的。要比前缀后缀复杂得多,当然重载就不涉及,因为是系统默认的优先级。

默认的系统自带的我搬运到后面。

定义中缀运算符首先要制定结合型和优先级。

假设计算两个点之间的距离

operator infix <~> {
    precedence 250 // 0~255 的一个值,具体多少请参考附录的列表
    associativity left // 或者right, none
}
@infix func <~> (pt0: Point, pt1: Point) -> Double {
    return .... // x 之差平方 +  y 之差平方,然后开放
}

带赋值的运算符

前面说了一堆,其实忽略了一些特殊的情况,比如 “+=”, “++”, 它们的特点是,会修改原有的操作数,有赋值副作用。实际上实现起来大同小异。

@prefix @assignment func ++ (inout pt: Point) -> Point {
    pt.x += 1
    pt.y += 1
    return pt
}

这里起作用的是 @assignment 属性,和 inout 关键字。

对于 “+=” 二元操作,第一个操作数需要标记为 inout。类似。大家自己研究好了。

附录

从手册里搬运下优先级和结合性:

级别 0~255

  • Exponentiative (No associativity, precedence level 160)
    • << Bitwise left shift
    • >> Bitwise right shift
  • Multiplicative (Left associative, precedence level 150)
    • * Multiply
    • / Divide
    • % Remainder
    • &* Multiply, ignoring overflow
    • &/ Divide, ignoring overflow
    • &% Remainder, ignoring overflow
    • & Bitwise AND
  • Additive (Left associative, precedence level 140)
    • + Add
    • - Subtract
    • &+ Add with overflow
    • &- Subtract with overflow
    • | Bitwise OR
    • ^ Bitwise XOR
  • Range (No associativity, precedence level 135)
    • .. Half-closed range
    • ... Closed range
  • Cast (No associativity, precedence level 132)
    • is Type check
    • as Type cast
  • Comparative (No associativity, precedence level 130)
    • < Less than
    • <= Less than or equal
    • > Greater than
    • >= Greater than or equal
    • == Equal
    • != Not equal
    • === Identical
    • !== Not identical
    • ~= Pattern match
  • Conjunctive (Left associative, precedence level 120)
    • && Logical AND
  • Disjunctive (Left associative, precedence level 110)
    • || Logical OR
  • Ternary Conditional (Right associative, precedence level 100)
    • ?: Ternary conditional
  • Assignment (Right associative, precedence level 90)
    • = Assign
    • *= Multiply and assign
    • /= Divide and assign
    • %= Remainder and assign
    • += Add and assign
    • -= Subtract and assign
    • <<= Left bit shift and assign
    • >>= Right bit shift and assign
    • &= Bitwise AND and assign
    • ^= Bitwise XOR and assign
    • |= Bitwise OR and assign
    • &&= Logical AND and assign
    • ||= Logical OR and assign

Rust Tips

extern crate

1
extern crate sdl2 = "github.com/andelf/rust-sdl2";

A Rustdoc Plugin

Run with

rustdoc -L. --plugin-path . --plugins dummy rust-sdl2/src/sdl2/lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#![crate_id = "dummy#0.1"]
#![crate_type = "dylib"]


extern crate rustdoc;

use rustdoc::clean;

use rustdoc::plugins::{PluginCallback, PluginResult, PluginJson};

#[no_mangle]
pub fn rustdoc_plugin_entrypoint(c: clean::Crate) -> PluginResult {
    println!("loading extension ok!");
    println!("crate => {}", c.name);
    (c, None)
}

Rust Tokenizer

A rust tokenizer from rust standard library.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
extern crate syntax;

use syntax::parse;
use syntax::ast;

fn main() {
    let sess = parse::new_parse_sess();
    let cfg = Vec::new();
    let mut p = parse::new_parser_from_file(&sess, cfg, &Path::new("./mytest.rs"));
    while p.token != parse::token::EOF {
        p.bump();
        println!("debug => {}", parse::token::to_str(&p.token));
    }
}

DONE!

p.parse_token_tree() will return a TokenTree, which is a nested token list.