/
Attr.def
272 lines (208 loc) · 8.88 KB
/
Attr.def
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
264
265
266
267
268
269
270
271
272
//===--- Attr.def - Swift Attributes Metaprogramming ------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines macros used for macro-metaprogramming with attributes.
//
//===----------------------------------------------------------------------===//
#ifndef DECL_ATTR
#define DECL_ATTR(SPELLING, CLASS, OPTIONS, CODE)
#endif
#ifndef SIMPLE_DECL_ATTR
#define SIMPLE_DECL_ATTR(X, CLASS, OPTIONS, CODE) DECL_ATTR(X, CLASS, OPTIONS, CODE)
#endif
#ifndef DECL_ATTR_ALIAS
#define DECL_ATTR_ALIAS(SPELLING, CLASS)
#endif
#ifndef TYPE_ATTR
#define TYPE_ATTR(X)
#endif
// Type attributes
TYPE_ATTR(autoclosure)
TYPE_ATTR(convention)
TYPE_ATTR(noreturn)
TYPE_ATTR(noescape)
TYPE_ATTR(escaping)
// SIL-specific attributes
TYPE_ATTR(block_storage)
TYPE_ATTR(box)
TYPE_ATTR(sil_unowned)
TYPE_ATTR(sil_unmanaged)
TYPE_ATTR(sil_weak)
TYPE_ATTR(error)
TYPE_ATTR(out)
TYPE_ATTR(in)
TYPE_ATTR(inout)
TYPE_ATTR(inout_aliasable)
TYPE_ATTR(in_guaranteed)
TYPE_ATTR(owned)
TYPE_ATTR(unowned_inner_pointer)
TYPE_ATTR(guaranteed)
TYPE_ATTR(autoreleased)
TYPE_ATTR(callee_owned)
TYPE_ATTR(callee_guaranteed)
TYPE_ATTR(objc_metatype)
TYPE_ATTR(opened)
TYPE_ATTR(deallocating)
TYPE_ATTR(pseudogeneric)
// SIL metatype attributes.
TYPE_ATTR(thin)
TYPE_ATTR(thick)
// Schema for DECL_ATTR:
//
// - Attribute name.
// - Class name without the 'Attr' suffix (ignored for
// - Options for the attribute, including:
// * the declarations the attribute can appear on
// * whether duplicates are allowed
// * whether the attribute is considered a decl modifier or not (no '@')
// - Unique attribute identifier used for serialization. This
// can never be changed.
//
// SIMPLE_DECL_ATTR is the same, but the class becomes
// SimpleDeclAttr<DAK_##NAME>.
//
DECL_ATTR(_silgen_name, SILGenName,
OnFunc | OnConstructor | OnDestructor | LongAttribute |
UserInaccessible, 0)
DECL_ATTR(available, Available,
OnFunc | OnStruct | OnEnum | OnClass | OnProtocol | OnVar |
OnConstructor | OnDestructor | OnTypeAlias | OnSubscript |
OnEnumElement | OnExtension | AllowMultipleAttributes | LongAttribute, 1)
SIMPLE_DECL_ATTR(final, Final,
OnClass | OnFunc | OnVar | OnSubscript|DeclModifier, 2)
DECL_ATTR(objc, ObjC,
OnFunc | OnClass | OnProtocol | OnVar | OnSubscript |
OnConstructor | OnDestructor | OnEnum | OnEnumElement, 3)
SIMPLE_DECL_ATTR(required, Required,
OnConstructor|DeclModifier, 4)
SIMPLE_DECL_ATTR(optional, Optional,
OnConstructor|OnFunc|OnVar|OnSubscript|DeclModifier, 5)
DECL_ATTR(swift3_migration, Swift3Migration,
OnEnum | OnStruct | OnClass | OnProtocol | OnTypeAlias |
OnVar | OnSubscript | OnConstructor | OnFunc | OnEnumElement |
OnGenericTypeParam | OnAssociatedType | LongAttribute, 6)
SIMPLE_DECL_ATTR(noreturn, NoReturn, OnFunc, 7)
SIMPLE_DECL_ATTR(_exported, Exported, OnImport | UserInaccessible, 8)
/// NOTE: 9 is unused.
SIMPLE_DECL_ATTR(NSCopying, NSCopying,
OnVar, 10)
SIMPLE_DECL_ATTR(IBAction, IBAction,
OnFunc, 11)
SIMPLE_DECL_ATTR(IBDesignable, IBDesignable,
OnClass | OnExtension, 12)
SIMPLE_DECL_ATTR(IBInspectable, IBInspectable,
OnVar, 13)
SIMPLE_DECL_ATTR(IBOutlet, IBOutlet,
OnVar, 14)
SIMPLE_DECL_ATTR(NSManaged, NSManaged, OnVar | OnFunc, 15)
SIMPLE_DECL_ATTR(lazy, Lazy, OnVar|DeclModifier, 16)
SIMPLE_DECL_ATTR(LLDBDebuggerFunction, LLDBDebuggerFunction, OnFunc |
UserInaccessible, 17)
SIMPLE_DECL_ATTR(UIApplicationMain, UIApplicationMain,
OnClass, 18)
SIMPLE_DECL_ATTR(unsafe_no_objc_tagged_pointer, UnsafeNoObjCTaggedPointer,
OnProtocol | UserInaccessible, 19)
DECL_ATTR(inline, Inline, OnFunc | OnConstructor, 20)
DECL_ATTR(_semantics, Semantics,
OnFunc | OnConstructor | OnDestructor | OnSubscript |
AllowMultipleAttributes | UserInaccessible, 21)
SIMPLE_DECL_ATTR(dynamic, Dynamic,
OnFunc | OnVar | OnSubscript | OnConstructor | DeclModifier, 22)
SIMPLE_DECL_ATTR(infix , Infix , OnFunc | OnOperator | DeclModifier, 23)
SIMPLE_DECL_ATTR(prefix , Prefix , OnFunc | OnOperator | DeclModifier, 24)
SIMPLE_DECL_ATTR(postfix, Postfix, OnFunc | OnOperator | DeclModifier, 25)
SIMPLE_DECL_ATTR(_transparent, Transparent,
OnFunc|OnConstructor|OnVar|OnExtension|UserInaccessible, 26)
SIMPLE_DECL_ATTR(requires_stored_property_inits, RequiresStoredPropertyInits,
OnClass, 27)
DECL_ATTR(autoclosure, AutoClosure, OnParam, 28)
SIMPLE_DECL_ATTR(noescape, NoEscape, OnParam, 29)
SIMPLE_DECL_ATTR(nonobjc, NonObjC,
OnFunc | OnVar | OnSubscript | OnConstructor, 30)
SIMPLE_DECL_ATTR(_fixed_layout, FixedLayout,
OnVar | OnClass | OnStruct | OnEnum | UserInaccessible, 31)
DECL_ATTR(_specialize, Specialize,
OnConstructor | OnFunc | AllowMultipleAttributes | LongAttribute
| UserInaccessible, 32)
// Non-serialized attributes.
SIMPLE_DECL_ATTR(mutating, Mutating, OnFunc | DeclModifier | NotSerialized,
/* Not serialized */ 41)
SIMPLE_DECL_ATTR(nonmutating, NonMutating, OnFunc | DeclModifier | NotSerialized,
/* Not serialized */ 42)
SIMPLE_DECL_ATTR(convenience, Convenience,
OnConstructor|DeclModifier|NotSerialized, 43)
SIMPLE_DECL_ATTR(override, Override,
OnFunc | OnVar | OnSubscript | OnConstructor | DeclModifier |
NotSerialized,
/* Not serialized */44)
SIMPLE_DECL_ATTR(sil_stored, SILStored, OnVar | NotSerialized | SILOnly,
/* Not serialized */45)
DECL_ATTR(private, Accessibility,
OnFunc | OnExtension | OnTypeAlias | OnStruct | OnEnum |
OnClass | OnProtocol | OnVar | OnSubscript | OnConstructor |
DeclModifier | NotSerialized,
/* Not serialized */ 46)
DECL_ATTR_ALIAS(fileprivate, Accessibility)
DECL_ATTR_ALIAS(internal, Accessibility)
DECL_ATTR_ALIAS(public, Accessibility)
DECL_ATTR(__accessibility, SetterAccessibility,
OnVar | OnSubscript | DeclModifier | NotSerialized | RejectByParser,
/* Not serialized */ 47)
DECL_ATTR(__raw_doc_comment, RawDocComment, OnAnyDecl |
NotSerialized | RejectByParser, /* Not serialized */48)
// Also handles unowned and unowned(weak).
DECL_ATTR(weak, Ownership, OnVar | OnParam | DeclModifier | NotSerialized,
/* Not serialized */49)
DECL_ATTR_ALIAS(unowned, Ownership)
DECL_ATTR(effects, Effects, OnFunc | OnConstructor | OnDestructor |
UserInaccessible, 50)
DECL_ATTR(__objc_bridged, ObjCBridged, OnClass | NotSerialized | RejectByParser,
/* Not serialized */51)
SIMPLE_DECL_ATTR(NSApplicationMain, NSApplicationMain,
OnClass, 52)
SIMPLE_DECL_ATTR(objc_non_lazy_realization, ObjCNonLazyRealization,
OnClass, 53)
DECL_ATTR(__synthesized_protocol, SynthesizedProtocol,
OnStruct | OnEnum | OnClass | NotSerialized | RejectByParser,
/* Not serialized */54)
SIMPLE_DECL_ATTR(testable, Testable,
OnImport | NotSerialized | UserInaccessible,
/* Not serialized */ 55)
DECL_ATTR(_alignment, Alignment, OnStruct | OnEnum | UserInaccessible, 56)
SIMPLE_DECL_ATTR(rethrows, Rethrows,
OnFunc | OnConstructor | RejectByParser, 57)
DECL_ATTR(_swift_native_objc_runtime_base, SwiftNativeObjCRuntimeBase,
OnClass | UserInaccessible, 59)
SIMPLE_DECL_ATTR(indirect, Indirect,
OnEnum | OnEnumElement | DeclModifier,
60)
SIMPLE_DECL_ATTR(warn_unqualified_access, WarnUnqualifiedAccess,
OnFunc /*| OnVar*/ | LongAttribute, 61)
SIMPLE_DECL_ATTR(_show_in_interface, ShowInInterface,
OnProtocol | UserInaccessible, 62)
DECL_ATTR(_cdecl, CDecl,
OnFunc | LongAttribute | UserInaccessible, 63)
// A testing attribute for Library Evolution ("resilience").
// FIXME: Replace with improved @available attribute.
SIMPLE_DECL_ATTR(_versioned, Versioned,
OnFunc | OnVar | OnSubscript | OnConstructor |
OnStruct | OnEnum | OnClass | OnProtocol |
LongAttribute | UserInaccessible,
64)
SIMPLE_DECL_ATTR(discardableResult, DiscardableResult,
OnFunc | OnConstructor | LongAttribute, 65)
SIMPLE_DECL_ATTR(GKInspectable, GKInspectable, OnVar, 66)
SIMPLE_DECL_ATTR(escaping, Escaping, OnParam, 67)
#undef TYPE_ATTR
#undef DECL_ATTR_ALIAS
#undef SIMPLE_DECL_ATTR
#undef DECL_ATTR