|
| 1 | +//// Automatically Generated From AttributeNodes.swift.gyb. |
| 2 | +//// Do Not Edit Directly! |
| 3 | +//===----------------------------------------------------------------------===// |
| 4 | +// |
| 5 | +// This source file is part of the Swift.org open source project |
| 6 | +// |
| 7 | +// Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors |
| 8 | +// Licensed under Apache License v2.0 with Runtime Library Exception |
| 9 | +// |
| 10 | +// See https://swift.org/LICENSE.txt for license information |
| 11 | +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| 12 | +// |
| 13 | +//===----------------------------------------------------------------------===// |
| 14 | + |
| 15 | +public class Attribute { |
| 16 | + public let name: String |
| 17 | + public let swiftName: String? |
| 18 | + |
| 19 | + public init(name: String, swiftName: String? = nil) { |
| 20 | + self.name = name |
| 21 | + self.swiftName = swiftName |
| 22 | + } |
| 23 | +} |
| 24 | + |
| 25 | +public class TypeAttribute: Attribute { |
| 26 | + public init(name: String) { |
| 27 | + super.init(name: name) |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +public class DeclAttribute: Attribute { |
| 32 | + public let className: String |
| 33 | + public let options: [String] |
| 34 | + public let code: Int |
| 35 | + |
| 36 | + public convenience init(name: String, className: String, options: String..., code: Int, swiftName: String? = nil) { |
| 37 | + self.init(name: name, className: className, options: options, code: code, swiftName: swiftName) |
| 38 | + } |
| 39 | + |
| 40 | + public init(name: String, className: String, options: [String], code: Int, swiftName: String? = nil) { |
| 41 | + self.className = className |
| 42 | + self.options = options |
| 43 | + self.code = code |
| 44 | + super.init(name: name, swiftName: swiftName) |
| 45 | + } |
| 46 | +} |
| 47 | + |
| 48 | +public class SimpleDeclAttribute: DeclAttribute { } |
| 49 | + |
| 50 | +public class ContextualDeclAttribute: DeclAttribute { |
| 51 | + public init(name: String, className: String, options: String..., code: Int) { |
| 52 | + super.init(name: name, className: className, options: options, code: code) |
| 53 | + } |
| 54 | +} |
| 55 | + |
| 56 | +public class ContextualSimpleDeclAttribute: SimpleDeclAttribute { |
| 57 | + public init(name: String, className: String, options: String..., code: Int) { |
| 58 | + super.init(name: name, className: className, options: options, code: code) |
| 59 | + } |
| 60 | +} |
| 61 | + |
| 62 | +public class DeclAttributeAlias: Attribute { |
| 63 | + public let className: String |
| 64 | + |
| 65 | + public init(name: String, className: String, swiftName: String? = nil) { |
| 66 | + self.className = className |
| 67 | + super.init(name: name, swiftName: swiftName) |
| 68 | + |
| 69 | + } |
| 70 | +} |
| 71 | + |
| 72 | +public class ContextualDeclAttributeAlias: DeclAttributeAlias { } |
| 73 | + |
| 74 | +public class BuiltinDeclModifier: Attribute { } |
| 75 | + |
| 76 | +// Abstract class aggregations for use in Attr.def. |
| 77 | +let onValue = "OnValue" |
| 78 | +let onTypeAlias = "OnTypeAlias" |
| 79 | +let onEnumElement = "OnEnumElement" |
| 80 | +let onSubscript = "OnSubscript" |
| 81 | +let onVar = "OnVar" |
| 82 | +let onExtension = "OnExtension" |
| 83 | +let onClass = "OnClass" |
| 84 | +let onFunc = "OnFunc" |
| 85 | +let onAccessor = "OnAccessor" |
| 86 | +let onEnum = "OnEnum" |
| 87 | +let onConstructor = "OnConstructor" |
| 88 | +let onStruct = "OnStruct" |
| 89 | +let onImport = "OnImport" |
| 90 | +let onAssociatedType = "OnAssociatedType" |
| 91 | +let onGenericTypeParam = "OnGenericTypeParam" |
| 92 | +let onParam = "OnParam" |
| 93 | +let onNominalType = "OnNominalType" |
| 94 | +let onProtocol = "OnProtocol" |
| 95 | +let onConcreteNominalType = "OnConcreteNominalType" |
| 96 | +let onGenericType = "OnGenericType" |
| 97 | +let onAbstractFunction = "OnAbstractFunction" |
| 98 | +let onOperator = "OnOperator" |
| 99 | +let onAnyDecl = "OnAnyDecl" |
| 100 | + |
| 101 | +// True if multiple instances of this attribute are allowed on a single |
| 102 | +// declaration. |
| 103 | +let allowMultipleAttributes = "AllowMultipleAttributes" |
| 104 | + |
| 105 | +// True if this is a decl modifier - i.e., that it should not be spelled |
| 106 | +// with an @. |
| 107 | +let declModifier = "DeclModifier" |
| 108 | + |
| 109 | +// True if this is a long attribute that should be printed on its own line. |
| 110 | +// |
| 111 | +// Currently has no effect on DeclModifier attributes. |
| 112 | +let longAttribute = "LongAttribute" |
| 113 | + |
| 114 | +// True if this shouldn't be serialized. |
| 115 | +let notSerialized = "NotSerialized" |
| 116 | + |
| 117 | +// True if this attribute is only valid when parsing a .sil file. |
| 118 | +let SILOnly = "SILOnly" |
| 119 | + |
| 120 | +// The attribute should be reported by parser as unknown. |
| 121 | +let rejectByParser = "RejectByParser" |
| 122 | + |
| 123 | +// Whether client code cannot use the attribute. |
| 124 | +let userInaccessible = "UserInaccessible" |
| 125 | + |
| 126 | +// Whether adding this attribute can break API |
| 127 | +let APIBreakingToAdd = "APIBreakingToAdd" |
| 128 | + |
| 129 | +// Whether removing this attribute can break API |
| 130 | +let APIBreakingToRemove = "APIBreakingToRemove" |
| 131 | + |
| 132 | +// Whether adding this attribute can break ABI |
| 133 | +let ABIBreakingToAdd = "ABIBreakingToAdd" |
| 134 | + |
| 135 | +// Whether removing this attribute can break ABI |
| 136 | +let ABIBreakingToRemove = "ABIBreakingToRemove" |
| 137 | + |
| 138 | +// The opposite of APIBreakingToAdd |
| 139 | +let APIStableToAdd = "APIStableToAdd" |
| 140 | + |
| 141 | +// The opposite of APIBreakingToRemove |
| 142 | +let APIStableToRemove = "APIStableToRemove" |
| 143 | + |
| 144 | +// The opposite of ABIBreakingToAdd |
| 145 | +let ABIStableToAdd = "ABIStableToAdd" |
| 146 | + |
| 147 | +// The opposite of ABIBreakingToRemove |
| 148 | +let ABIStableToRemove = "ABIStableToRemove" |
| 149 | + |
| 150 | +// Whether this attribute is only valid when concurrency is enabled. |
| 151 | +let concurrencyOnly = "ConcurrencyOnly" |
| 152 | + |
| 153 | +// Whether this attribute is valid on additional decls in ClangImporter. |
| 154 | +let onAnyClangDecl = "OnAnyClangDecl" |
| 155 | + |
| 156 | +// Type attributes |
| 157 | +public let TYPE_ATTR_KINDS = [ |
| 158 | + TypeAttribute(name: "autoclosure"), |
| 159 | + TypeAttribute(name: "convention"), |
| 160 | + TypeAttribute(name: "noescape"), |
| 161 | + TypeAttribute(name: "escaping"), |
| 162 | + TypeAttribute(name: "differentiable"), |
| 163 | + TypeAttribute(name: "noDerivative"), |
| 164 | + TypeAttribute(name: "async"), |
| 165 | + TypeAttribute(name: "Sendable"), |
| 166 | + TypeAttribute(name: "unchecked"), |
| 167 | + TypeAttribute(name: "_local"), |
| 168 | + TypeAttribute(name: "_noMetadata"), |
| 169 | + |
| 170 | + // Generated interface attributes |
| 171 | + TypeAttribute(name: "_opaqueReturnTypeOf"), |
| 172 | +] |
| 173 | + |
| 174 | +/// Schema for `DeclAttribute`s: |
| 175 | +/// |
| 176 | +/// - Attribute name. |
| 177 | +/// - C++ class name without the 'Attr' suffix |
| 178 | +/// - Options for the attribute, including: |
| 179 | +/// * the declarations the attribute can appear on |
| 180 | +/// * whether duplicates are allowed |
| 181 | +/// - Unique attribute identifier used for serialization. This |
| 182 | +/// can never be changed. |
| 183 | +/// |
| 184 | +/// SimpleDeclAttribute is the same, but the class becomes |
| 185 | +/// SimpleDeclAttr<DAK_##NAME> on the C++ side. |
| 186 | +/// |
| 187 | +/// Please help ease code review/audits: |
| 188 | +/// - Please place the "OnXYZ" flags together on the next line. |
| 189 | +/// - Please place the non-OnXYZ flags together on the next to last line. |
| 190 | +/// - Please place the unique code number on the last line. |
| 191 | +/// - Please sort attributes by serialization number. |
| 192 | +/// - Please create a "NOTE" comment if a unique number is skipped. |
| 193 | +/// |
| 194 | +/// If you're adding a new kind of "attribute" that is spelled without a leading |
| 195 | +/// '@' symbol, add an entry to the `DECL_MODIFIER_KINDS` array instead. |
| 196 | +/// |
| 197 | +/// If you're adding a new underscored attribute here, please document it in |
| 198 | +/// docs/ReferenceGuides/UnderscoredAttributes.md. |
| 199 | +public let DECL_ATTR_KINDS: [Attribute] = [ |
| 200 | + |
| 201 | +] |
| 202 | + |
| 203 | +/// Schema for declaration modifiers: |
| 204 | +/// |
| 205 | +/// - Modifier name. |
| 206 | +/// - C++ class name without the 'Attr' suffix |
| 207 | +/// - Options for the attribute, including: |
| 208 | +/// * the declarations the attribute can appear on |
| 209 | +/// * whether duplicates are allowed |
| 210 | +/// - Unique attribute identifier used for serialization. This |
| 211 | +/// can never be changed. |
| 212 | +/// |
| 213 | +/// SimpleDeclAttribute is the same, but the class becomes |
| 214 | +/// SimpleDeclAttr<DAK_##NAME> on the C++ side. |
| 215 | +/// |
| 216 | +/// Please help ease code review/audits: |
| 217 | +/// - Please place the "OnXYZ" flags together on the next line. |
| 218 | +/// - Please place the non-OnXYZ flags together on the next to last line. |
| 219 | +/// - Please place the unique code number on the last line. |
| 220 | +/// - Please sort attributes by serialization number. |
| 221 | +/// - Please create a "NOTE" comment if a unique number is skipped. |
| 222 | +/// |
| 223 | +/// If you're adding a new kind of attribute that is spelled with a leading |
| 224 | +/// '@' symbol, add an entry to the `DECL_ATTR_KINDS` array instead. |
| 225 | +public let DECL_MODIFIER_KINDS: [Attribute] = [ |
| 226 | + |
| 227 | +] |
| 228 | + |
| 229 | +public let DEPRECATED_MODIFIER_KINDS: [Attribute] = [ |
| 230 | + |
| 231 | +] |
| 232 | + |
| 233 | +// def verify_attribute_serialization_codes(nodes): |
| 234 | +// # Verify that no serialization code is used twice |
| 235 | +// used_codes = set() |
| 236 | +// for node in nodes: |
| 237 | +// if isinstance(node, DeclAttribute): |
| 238 | +// if node.code in used_codes: |
| 239 | +// error("Serialization code %d used twice" % node.code) |
| 240 | +// used_codes.add(node.code) |
0 commit comments