@@ -18,101 +18,4 @@ public typealias _CompilerPlugin = Any
18
18
#endif
19
19
20
20
/// Describes a macro.
21
- public protocol Macro : _CompilerPlugin {
22
- /// The name of this macro.
23
- static var name : String { get }
24
-
25
- /// Documentation for this macro.
26
- ///
27
- /// This documentation should be written in the Markdown format used for
28
- /// commenting Swift declarations.
29
- static var documentation : String { get }
30
-
31
- /// The generic signature to use when describing the type of this macro.
32
- static var genericSignature : GenericParameterClauseSyntax ? { get }
33
-
34
- /// The type signature for this macro.
35
- ///
36
- /// A function type indicates a function-like macro (such as
37
- /// `#colorLiteral(red: r, green: b, blue: b, alpha: a)`) that takes
38
- /// arguments, whereas any other type indicates a value-like macro (such
39
- /// as `#line`) that does not. This is a syntactic distinction, not a
40
- /// semantic one.
41
- static var signature : TypeSyntax { get }
42
-
43
- /// The module that "owns" this macro.
44
- ///
45
- /// This module must be imported by any code that wishes to use the macro.
46
- static var owningModule : String { get }
47
-
48
- /// Additional imports requires to describe the signature of the macro.
49
- ///
50
- /// For example, if your macro is owned by module A, but its signature also
51
- /// contains types from another module B that is used by A, then the module
52
- /// B should be
53
- static var supplementalSignatureModules : [ String ] { get }
54
- }
55
-
56
- extension Macro {
57
- /// Default, empty documentation string for macros.
58
- public static var documentation : String { " " }
59
-
60
- /// Default, empty set of supplemental signature modules.
61
- ///
62
- /// Many macros won't need any supplemental signature modules beyond the
63
- /// default "Swift" import.
64
- public static var supplementalSignatureModules : [ String ] { [ ] }
65
- }
66
-
67
- #if canImport(_CompilerPluginSupport)
68
- extension Macro {
69
- public static func _name( ) -> ( UnsafePointer < UInt8 > , count: Int ) {
70
- var name = name
71
- return name. withUTF8 { buffer in
72
- let result = UnsafeMutablePointer< UInt8> . allocate( capacity: buffer. count)
73
- result. initialize ( from: buffer. baseAddress!, count: buffer. count)
74
- return ( UnsafePointer ( result) , count: buffer. count)
75
- }
76
- }
77
-
78
- public static func _genericSignature( ) -> ( UnsafePointer < UInt8 > ? , count: Int ) {
79
- guard let genericSignature = genericSignature else {
80
- return ( nil , count: 0 )
81
- }
82
- var signature = " \( genericSignature) "
83
- return signature. withUTF8 { buffer in
84
- let result = UnsafeMutablePointer< UInt8> . allocate( capacity: buffer. count)
85
- result. initialize ( from: buffer. baseAddress!, count: buffer. count)
86
- return ( UnsafePointer ( result) , count: buffer. count)
87
- }
88
- }
89
-
90
- public static func _typeSignature( ) -> ( UnsafePointer < UInt8 > , count: Int ) {
91
- var signature = " \( signature) "
92
- return signature. withUTF8 { buffer in
93
- let result = UnsafeMutablePointer< UInt8> . allocate( capacity: buffer. count)
94
- result. initialize ( from: buffer. baseAddress!, count: buffer. count)
95
- return ( UnsafePointer ( result) , count: buffer. count)
96
- }
97
- }
98
-
99
- public static func _owningModule( ) -> ( UnsafePointer < UInt8 > , count: Int ) {
100
- var module = " \( owningModule) "
101
- return module. withUTF8 { buffer in
102
- let result = UnsafeMutablePointer< UInt8> . allocate( capacity: buffer. count)
103
- result. initialize ( from: buffer. baseAddress!, count: buffer. count)
104
- return ( UnsafePointer ( result) , count: buffer. count)
105
- }
106
- }
107
-
108
- public static func _supplementalSignatureModules( )
109
- -> ( UnsafePointer < UInt8 > , count: Int ) {
110
- var allModulesJoined = supplementalSignatureModules. joined ( separator: " ; " )
111
- return allModulesJoined. withUTF8 { buffer in
112
- let result = UnsafeMutablePointer< UInt8> . allocate( capacity: buffer. count)
113
- result. initialize ( from: buffer. baseAddress!, count: buffer. count)
114
- return ( UnsafePointer ( result) , count: buffer. count)
115
- }
116
- }
117
- }
118
- #endif
21
+ public protocol Macro : _CompilerPlugin { }
0 commit comments