@@ -23,13 +23,13 @@ public enum ComponentMacroError: Error, CustomStringConvertible {
2323 }
2424}
2525
26- public struct ECSComponentMacro : MemberMacro , ExtensionMacro {
26+ public struct ECSComponentMacro : ExtensionMacro {
2727 public static func expansion(
28- of node: SwiftSyntax . AttributeSyntax ,
29- attachedTo declaration: some SwiftSyntax . DeclGroupSyntax ,
30- providingExtensionsOf type: some SwiftSyntax . TypeSyntaxProtocol ,
31- conformingTo protocols: [ SwiftSyntax . TypeSyntax ] ,
32- in context: some SwiftSyntaxMacros . MacroExpansionContext
28+ of node: AttributeSyntax ,
29+ attachedTo declaration: some DeclGroupSyntax ,
30+ providingExtensionsOf type: some TypeSyntaxProtocol ,
31+ conformingTo protocols: [ TypeSyntax ] ,
32+ in context: some MacroExpansionContext
3333 ) throws -> [ SwiftSyntax . ExtensionDeclSyntax ] {
3434 let isClass = declaration. as ( ClassDeclSyntax . self) != nil
3535 guard let name = declaration. as ( ClassDeclSyntax . self) ? . name. trimmed ?? declaration. as ( StructDeclSyntax . self) ? . name. trimmed else {
@@ -56,38 +56,10 @@ public struct ECSComponentMacro: MemberMacro, ExtensionMacro {
5656 } ) ? . trimmedDescription ?? " "
5757
5858 let extensionBody = " \( access) static let componentID: GateEngine.ComponentID = .init() "
59-
60- // let find = try InitializerDeclSyntax("init()") {
61- //
62- // }
63-
64- // if declaration.memberBlock.members.compactMap({InitializerDeclSyntax($0)}).isEmpty == true {
65- // extensionBody = "\(access) init() { }" + "\n" + extensionBody
66- // }
67-
6859 extensionDeclaration += " { \n " + extensionBody + " \n } "
6960
7061 return [
7162 try ExtensionDeclSyntax ( SyntaxNodeString ( stringLiteral: extensionDeclaration) )
7263 ]
7364 }
74-
75- // public static func expansion(
76- // of node: SwiftSyntax.AttributeSyntax,
77- // providingPeersOf declaration: some SwiftSyntax.DeclSyntaxProtocol,
78- // in context: some SwiftSyntaxMacros.MacroExpansionContext
79- // ) throws -> [SwiftSyntax.DeclSyntax] {
80- // guard let classDecl = declaration.as(ClassDeclSyntax.self) else {
81- // throw SystemMacroError.notClass
82- // }
83- // let className = classDecl.name.trimmed
84- // return [DeclSyntax(
85- //"""
86- //@_cdecl(\"eventHandler\")
87- //fileprivate func _eventHandler(pointer: UnsafeMutableRawPointer!, event: System.Event, arg: CUnsignedInt) -> CInt {
88- // return \(className)._eventHandler(pointer: pointer, event: event, arg: arg)
89- //}
90- //"""
91- // )]
92- // }
9365}
0 commit comments