-
Notifications
You must be signed in to change notification settings - Fork 10.2k
/
Attr.def
208 lines (160 loc) · 6.35 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
//===--- Attr.def - Swift Attributes Metaprogramming ------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 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
#ifndef AVAILABILITY_PLATFORM
#define AVAILABILITY_PLATFORM(X, PrettyName)
#endif
// Type attributes
TYPE_ATTR(autoclosure)
TYPE_ATTR(cc)
TYPE_ATTR(noreturn)
TYPE_ATTR(objc_block)
TYPE_ATTR(thin)
TYPE_ATTR(thick)
// SIL-specific attributes
TYPE_ATTR(block_storage)
TYPE_ATTR(sil_self)
TYPE_ATTR(local_storage)
TYPE_ATTR(sil_unowned)
TYPE_ATTR(sil_unmanaged)
TYPE_ATTR(sil_weak)
TYPE_ATTR(out)
TYPE_ATTR(in)
TYPE_ATTR(inout)
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)
// 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(asmname, Asmname,
OnFunc | OnConstructor | OnDestructor | LongAttribute, 0)
DECL_ATTR(availability, Availability,
OnFunc | OnStruct | OnEnum | OnClass | OnProtocol | OnVar |
OnConstructor | OnDestructor | OnTypeAlias | OnSubscript |
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, 3)
SIMPLE_DECL_ATTR(required, Required,
OnConstructor|DeclModifier, 4)
SIMPLE_DECL_ATTR(optional, Optional,
OnConstructor|OnFunc|OnVar|OnSubscript|DeclModifier, 5)
SIMPLE_DECL_ATTR(class_protocol, ClassProtocol, OnProtocol, 6)
SIMPLE_DECL_ATTR(noreturn, NoReturn, OnFunc, 7)
SIMPLE_DECL_ATTR(exported, Exported, OnImport, 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, 12)
SIMPLE_DECL_ATTR(IBInspectable, IBInspectable,
OnVar, 13)
SIMPLE_DECL_ATTR(IBOutlet, IBOutlet,
OnVar, 14)
SIMPLE_DECL_ATTR(NSManaged, NSManaged, OnVar, 15)
SIMPLE_DECL_ATTR(lazy, Lazy, OnVar|DeclModifier, 16)
SIMPLE_DECL_ATTR(LLDBDebuggerFunction, LLDBDebuggerFunction,
OnFunc, 17)
SIMPLE_DECL_ATTR(UIApplicationMain, UIApplicationMain,
OnClass, 18)
SIMPLE_DECL_ATTR(unsafe_no_objc_tagged_pointer, UnsafeNoObjCTaggedPointer,
OnProtocol, 19)
DECL_ATTR(inline, Inline, OnFunc | OnConstructor, 20)
DECL_ATTR(semantics, Semantics,
OnFunc | OnConstructor | OnDestructor | OnSubscript, 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, 26)
SIMPLE_DECL_ATTR(requires_stored_property_inits, RequiresStoredPropertyInits,
OnClass, 27)
// Non-serialized attributes.
SIMPLE_DECL_ATTR(mutating, Mutating, OnFunc | DeclModifier | NotSerialized,
/* Not serialized */ 28)
SIMPLE_DECL_ATTR(nonmutating, NonMutating, OnFunc | DeclModifier | NotSerialized,
/* Not serialized */ 29)
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(internal, Accessibility)
DECL_ATTR_ALIAS(public, Accessibility)
DECL_ATTR(__accessibility, SetterAccessibility,
OnVar | OnSubscript | DeclModifier | NotSerialized,
/* Not serialized */ 47)
DECL_ATTR(__raw_doc_comment, RawDocComment, OnAnyDecl | NotSerialized,
/* Not serialized */48)
// Also handles unowned and unowned(weak).
DECL_ATTR(weak, Ownership, OnVar | OnParam | DeclModifier | NotSerialized,
/* Not serialized */49)
DECL_ATTR(effects, Effects, OnFunc, 50)
DECL_ATTR_ALIAS(unowned, Ownership)
DECL_ATTR(__objc_bridged, ObjCBridged, OnClass | NotSerialized,
/* Not serialized */51)
// Reordering these platforms will break serialization.
AVAILABILITY_PLATFORM(iOS, "iOS")
AVAILABILITY_PLATFORM(OSX, "OS X")
AVAILABILITY_PLATFORM(iOSApplicationExtension, "iOS application extension")
AVAILABILITY_PLATFORM(OSXApplicationExtension, "OS X application extension")
#undef AVAILABILITY_PLATFORM
#undef TYPE_ATTR
#undef DECL_ATTR_ALIAS
#undef SIMPLE_DECL_ATTR
#undef DECL_ATTR