|
| 1 | +%{ |
| 2 | + # -*- mode: C++ -*- |
| 3 | + from gyb_syntax_support import * |
| 4 | + from gyb_syntax_support.AttributeKinds import * |
| 5 | + # Ignore the following admonition; it applies to the resulting .def file only |
| 6 | +}% |
| 7 | +//// Automatically Generated From Attr.def.gyb. |
| 8 | +//// Do Not Edit Directly! |
| 9 | +//===--- Attr.def - Swift Attributes Metaprogramming ------------*- C++ -*-===// |
| 10 | +// |
| 11 | +// This source file is part of the Swift.org open source project |
| 12 | +// |
| 13 | +// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors |
| 14 | +// Licensed under Apache License v2.0 with Runtime Library Exception |
| 15 | +// |
| 16 | +// See https://swift.org/LICENSE.txt for license information |
| 17 | +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| 18 | +// |
| 19 | +//===----------------------------------------------------------------------===// |
| 20 | +// |
| 21 | +// This file defines macros used for macro-metaprogramming with attributes. |
| 22 | +// |
| 23 | +//===----------------------------------------------------------------------===// |
| 24 | + |
| 25 | +#ifndef DECL_ATTR |
| 26 | +#define DECL_ATTR(SPELLING, CLASS, OPTIONS, CODE) |
| 27 | +#endif |
| 28 | + |
| 29 | +#ifndef CONTEXTUAL_DECL_ATTR |
| 30 | +#define CONTEXTUAL_DECL_ATTR(SPELLING, CLASS, OPTIONS, CODE) \ |
| 31 | + DECL_ATTR(SPELLING, CLASS, OPTIONS, CODE) |
| 32 | +#endif |
| 33 | + |
| 34 | +#ifndef SIMPLE_DECL_ATTR |
| 35 | +#define SIMPLE_DECL_ATTR(X, CLASS, OPTIONS, CODE) \ |
| 36 | + DECL_ATTR(X, CLASS, OPTIONS, CODE) |
| 37 | +#endif |
| 38 | + |
| 39 | +#ifndef CONTEXTUAL_SIMPLE_DECL_ATTR |
| 40 | +#define CONTEXTUAL_SIMPLE_DECL_ATTR(X, CLASS, OPTIONS, CODE) \ |
| 41 | + SIMPLE_DECL_ATTR(X, CLASS, OPTIONS, CODE) |
| 42 | +#endif |
| 43 | + |
| 44 | +#ifndef DECL_ATTR_ALIAS |
| 45 | +#define DECL_ATTR_ALIAS(SPELLING, CLASS) |
| 46 | +#endif |
| 47 | + |
| 48 | +#ifndef CONTEXTUAL_DECL_ATTR_ALIAS |
| 49 | +#define CONTEXTUAL_DECL_ATTR_ALIAS(SPELLING, CLASS) \ |
| 50 | + DECL_ATTR_ALIAS(SPELLING, CLASS) |
| 51 | +#endif |
| 52 | + |
| 53 | +#ifndef TYPE_ATTR |
| 54 | +#define TYPE_ATTR(X) |
| 55 | +#endif |
| 56 | + |
| 57 | +// Type attributes |
| 58 | +% for attr in TYPE_ATTR_KINDS: |
| 59 | +TYPE_ATTR(${attr.name}) |
| 60 | +% end |
| 61 | + |
| 62 | +// SIL-specific attributes |
| 63 | +TYPE_ATTR(block_storage) |
| 64 | +TYPE_ATTR(box) |
| 65 | +TYPE_ATTR(dynamic_self) |
| 66 | +#define REF_STORAGE(Name, name, ...) TYPE_ATTR(sil_##name) |
| 67 | +#include "swift/AST/ReferenceStorage.def" |
| 68 | +TYPE_ATTR(error) |
| 69 | +TYPE_ATTR(out) |
| 70 | +TYPE_ATTR(in) |
| 71 | +TYPE_ATTR(inout) |
| 72 | +TYPE_ATTR(inout_aliasable) |
| 73 | +TYPE_ATTR(in_guaranteed) |
| 74 | +TYPE_ATTR(in_constant) |
| 75 | +TYPE_ATTR(owned) |
| 76 | +TYPE_ATTR(unowned_inner_pointer) |
| 77 | +TYPE_ATTR(guaranteed) |
| 78 | +TYPE_ATTR(autoreleased) |
| 79 | +TYPE_ATTR(callee_owned) |
| 80 | +TYPE_ATTR(callee_guaranteed) |
| 81 | +TYPE_ATTR(objc_metatype) |
| 82 | +TYPE_ATTR(opened) |
| 83 | +TYPE_ATTR(pseudogeneric) |
| 84 | +TYPE_ATTR(yields) |
| 85 | +TYPE_ATTR(yield_once) |
| 86 | +TYPE_ATTR(yield_many) |
| 87 | +TYPE_ATTR(captures_generics) |
| 88 | +// Used at the SIL level to mark a type as moveOnly. |
| 89 | +TYPE_ATTR(moveOnly) |
| 90 | + |
| 91 | +// SIL metatype attributes. |
| 92 | +TYPE_ATTR(thin) |
| 93 | +TYPE_ATTR(thick) |
| 94 | + |
| 95 | +// Declaration Attributes and Modifers |
| 96 | +// To add a new entry here, update https://github.com/apple/swift-syntax |
| 97 | +% for attr in DECL_ATTR_KINDS + DECL_MODIFIER_KINDS + DEPRECATED_MODIFIER_KINDS: |
| 98 | +% if type(attr) is ContextualDeclAttributeAlias: |
| 99 | +CONTEXTUAL_DECL_ATTR_ALIAS(${attr.name}, ${attr.class_name}) |
| 100 | +% elif type(attr) is DeclAttributeAlias: |
| 101 | +DECL_ATTR_ALIAS(${attr.name}, ${attr.class_name}) |
| 102 | +% elif type(attr) is ContextualSimpleDeclAttribute: |
| 103 | +CONTEXTUAL_SIMPLE_DECL_ATTR(${attr.name}, ${attr.class_name}, |
| 104 | + ${' | '.join(attr.options)}, |
| 105 | + ${str(attr.code)}) |
| 106 | +% elif type(attr) is ContextualDeclAttribute: |
| 107 | +CONTEXTUAL_DECL_ATTR(${attr.name}, ${attr.class_name}, |
| 108 | + ${' | '.join(attr.options)}, |
| 109 | + ${str(attr.code)}) |
| 110 | +% elif type(attr) is SimpleDeclAttribute: |
| 111 | +SIMPLE_DECL_ATTR(${attr.name}, ${attr.class_name}, |
| 112 | + ${' | '.join(attr.options)}, |
| 113 | + ${str(attr.code)}) |
| 114 | +% elif type(attr) is DeclAttribute: |
| 115 | +DECL_ATTR(${attr.name}, ${attr.class_name}, |
| 116 | + ${' | '.join(attr.options)}, |
| 117 | + ${str(attr.code)}) |
| 118 | +% elif type(attr) is BuiltinDeclModifier: |
| 119 | +% # These are not actually decl attributes, ignore them. |
| 120 | +% pass |
| 121 | +% else: |
| 122 | +% raise RuntimeError(f'Unhandled attribute class {type(attr)}') |
| 123 | +% end |
| 124 | +% end |
| 125 | + |
| 126 | +#undef TYPE_ATTR |
| 127 | +#undef DECL_ATTR_ALIAS |
| 128 | +#undef CONTEXTUAL_DECL_ATTR_ALIAS |
| 129 | +#undef SIMPLE_DECL_ATTR |
| 130 | +#undef CONTEXTUAL_SIMPLE_DECL_ATTR |
| 131 | +#undef DECL_ATTR |
| 132 | +#undef CONTEXTUAL_DECL_ATTR |
0 commit comments