Home / Programming /
Disclaimer: This is not definitive, just my understanding.
Freestanding Expression macro
let a = #macroName(args)@freestanding(declaration, names: named(MyClass))
names is required, but it kinda seems like it is)[DeclSyntax]@freestanding(expression)ExprSyntaxAttached Macros
get, set, didSet, willSet, and more complex ones too (see docs)@attached(accessor)[AccessorDeclSyntax][CodeBlockItemSyntax]@attached(extension, conformances: Equatable)
[ExtensionDeclSyntax]Member
example declaration keyword:
@attached(
member,
names: named(Storage),
named(_storage),
named(_registrar),
named(addObserver),
named(removeObserver),
named(withTransaction)
)
names can take one or more arguments[DeclSyntax]I believe this means something like
@MahMancro
class Foo {}
Can expand to something like
class Foo {
var bar: Int
func baz () {}
}
MemberAttribute
@attached(memberAttribute)[AttributeSyntax]I believe this means something like
@MahMancro
class Foo {
var bar: Int
var baz: String
}
Can expand to something like
class Foo {
@MahSubMancro
var bar: Int
@MahSubMancro
var bax: String
}
Peer
examples of declaration keyword:
@attached(peer, names: overloaded)
@attached(peer, names: suffixed(_peer))
[DeclSyntax]I believe this means something like
@MahMancro
let url = URL(string: "https://the-google.com/")
Can expand to something like
let url = URL(string: "https://the-google.com/")
let url_request = URLRequest(url: url)
references:
this document last modified: April 22 2024 00:23
Home / Programming /