-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathExtensions.swift
168 lines (134 loc) · 4.58 KB
/
Extensions.swift
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
public extension RemObjects.Elements.RTL.String {
public func AsTypeReference() -> CGTypeReference {
return CGNamedTypeReference(self)
}
public func AsTypeReference(defaultNullability: CGTypeNullabilityKind) -> CGTypeReference {
return CGNamedTypeReference(self, defaultNullability: defaultNullability)
}
public func AsTypeReference(isClassType: Boolean) -> CGTypeReference {
return CGNamedTypeReference(self, isClassType: isClassType)
}
public func AsTypeReferenceExpression() -> CGTypeReferenceExpression {
return CGTypeReferenceExpression(CGNamedTypeReference(self))
}
public func AsTypeReferenceExpression(defaultNullability: CGTypeNullabilityKind) -> CGTypeReferenceExpression {
return CGTypeReferenceExpression(CGNamedTypeReference(self, defaultNullability: defaultNullability))
}
public func AsNamedIdentifierExpression() -> CGNamedIdentifierExpression {
return CGNamedIdentifierExpression(self)
}
public func AsLiteralExpression() -> CGStringLiteralExpression {
return CGStringLiteralExpression(self)
}
public func AsRawExpression() -> CGRawExpression {
return CGRawExpression(self)
}
public func AsCompilerDirective() -> CGCompilerDirective {
return CGCompilerDirective(self)
}
}
public extension RemObjects.Elements.System.String {
public func AsTypeReference() -> CGTypeReference {
return CGNamedTypeReference(self)
}
public func AsTypeReference(defaultNullability: CGTypeNullabilityKind) -> CGTypeReference {
return CGNamedTypeReference(self, defaultNullability: defaultNullability)
}
public func AsTypeReference(isClassType: Boolean) -> CGTypeReference {
return CGNamedTypeReference(self, isClassType: isClassType)
}
public func AsTypeReferenceExpression() -> CGTypeReferenceExpression {
return CGTypeReferenceExpression(CGNamedTypeReference(self))
}
public func AsTypeReferenceExpression(defaultNullability: CGTypeNullabilityKind) -> CGTypeReferenceExpression {
return CGTypeReferenceExpression(CGNamedTypeReference(self, defaultNullability: defaultNullability))
}
public func AsNamedIdentifierExpression() -> CGNamedIdentifierExpression {
return CGNamedIdentifierExpression(self)
}
public func AsLiteralExpression() -> CGStringLiteralExpression {
return CGStringLiteralExpression(self)
}
public func AsRawExpression() -> CGRawExpression {
return CGRawExpression(self)
}
public func AsCompilerDirective() -> CGCompilerDirective {
return CGCompilerDirective(self)
}
}
public extension Char {
public func AsLiteralExpression() -> CGCharacterLiteralExpression {
return CGCharacterLiteralExpression(self)
}
}
public extension Integer {
public func AsLiteralExpression() -> CGIntegerLiteralExpression {
return CGIntegerLiteralExpression(self)
}
//74375: Can't overload extension method, compiler claims signatures are same.
public func AsLiteralExpression(# base: Int32) -> CGIntegerLiteralExpression {
return CGIntegerLiteralExpression(self, base: base)
}
}
public extension Single {
public func AsLiteralExpression() -> CGFloatLiteralExpression {
return CGFloatLiteralExpression(self)
}
}
public extension Double {
public func AsLiteralExpression() -> CGFloatLiteralExpression {
return CGFloatLiteralExpression(self)
}
}
public extension Boolean {
public func AsLiteralExpression() -> CGBooleanLiteralExpression {
return CGBooleanLiteralExpression(self)
}
}
public extension CGExpression {
public func AsReturnStatement() -> CGReturnStatement {
return CGReturnStatement(self)
}
public func AsCallParameter() -> CGCallParameter {
return CGCallParameter(self)
}
public func AsCallParameter(_ name: String?) -> CGCallParameter {
if let name = name {
return CGCallParameter(self, name)
} else {
return CGCallParameter(self)
}
}
public func AsEllipsisCallParameter() -> CGCallParameter {
let result = CGCallParameter(self)
result.EllipsisParameter = true
return result
}
public func AsInvariant() -> CGInvariant {
return CGInvariant(self)
}
public func AsInvariant(_ message: String) -> CGInvariant {
return CGInvariant(self, message)
}
}
public extension CGTypeReference {
public func AsExpression() -> CGTypeReferenceExpression {
return CGTypeReferenceExpression(self)
}
}
public extension CGFieldDefinition {
public func AsGlobal() -> CGGlobalVariableDefinition {
return CGGlobalVariableDefinition(self)
}
}
public extension CGMethodDefinition {
public func AsGlobal() -> CGGlobalFunctionDefinition {
return CGGlobalFunctionDefinition(self)
}
}
@if(defined("TOFFEE") && exists(Swift.Array))
public extension Swift.Array {
public func ToList() -> List<T> {
return self.platformList.ToList()
}
}