//===--- 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 // Type attributes 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(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(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) // 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. // 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 | OnEnum, 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) SIMPLE_DECL_ATTR(objc_non_lazy_realization, ObjCNonLazyRealization, OnClass, 53) 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) SIMPLE_DECL_ATTR(autoclosure, AutoClosure, OnVar|OnParam, 28) SIMPLE_DECL_ATTR(__noescape, NoEscape, OnParam, 29) // 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(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 | OnConstructor | OnDestructor, 50) DECL_ATTR_ALIAS(unowned, Ownership) DECL_ATTR(__objc_bridged, ObjCBridged, OnClass | NotSerialized, /* Not serialized */51) SIMPLE_DECL_ATTR(NSApplicationMain, NSApplicationMain, OnClass, 52) #undef TYPE_ATTR #undef DECL_ATTR_ALIAS #undef SIMPLE_DECL_ATTR #undef DECL_ATTR