@@ -734,24 +734,40 @@ enum SwiftCodePattern {
734734 /// Builds the standard @_expose and @_cdecl attributes for WebAssembly-exposed functions
735735 static func buildExposeAttributes( abiName: String ) -> AttributeListSyntax {
736736 return AttributeListSyntax {
737+ #if canImport(SwiftSyntax602)
738+ let exposeAttrArgs = AttributeSyntax . Arguments. argumentList (
739+ [
740+ LabeledExprSyntax ( label: nil , expression: DeclReferenceExprSyntax ( baseName: " wasm " ) ) ,
741+ LabeledExprSyntax ( label: nil , expression: StringLiteralExprSyntax ( content: abiName) ) ,
742+ ]
743+ )
744+ let cdeclAttrArgs = AttributeSyntax . Arguments. argumentList (
745+ [
746+ LabeledExprSyntax ( label: nil , expression: StringLiteralExprSyntax ( content: abiName) )
747+ ]
748+ )
749+ #else
750+ let exposeAttrArgs = AttributeSyntax . Arguments. exposeAttributeArguments (
751+ ExposeAttributeArgumentsSyntax (
752+ language: . identifier( " wasm " ) ,
753+ comma: . commaToken( ) ,
754+ cxxName: StringLiteralExprSyntax ( content: abiName)
755+ )
756+ )
757+ let cdeclAttrArgs = AttributeSyntax . Arguments. string ( StringLiteralExprSyntax ( content: abiName) )
758+ #endif
737759 AttributeSyntax (
738760 attributeName: IdentifierTypeSyntax ( name: . identifier( " _expose " ) ) ,
739761 leftParen: . leftParenToken( ) ,
740- arguments: . exposeAttributeArguments(
741- ExposeAttributeArgumentsSyntax (
742- language: . identifier( " wasm " ) ,
743- comma: . commaToken( ) ,
744- cxxName: StringLiteralExprSyntax ( content: abiName)
745- )
746- ) ,
762+ arguments: exposeAttrArgs,
747763 rightParen: . rightParenToken( )
748764 )
749765 . with ( \. trailingTrivia, . newline)
750766
751767 AttributeSyntax (
752768 attributeName: IdentifierTypeSyntax ( name: . identifier( " _cdecl " ) ) ,
753769 leftParen: . leftParenToken( ) ,
754- arguments: . string ( StringLiteralExprSyntax ( content : abiName ) ) ,
770+ arguments: cdeclAttrArgs ,
755771 rightParen: . rightParenToken( )
756772 )
757773 . with ( \. trailingTrivia, . newline)
0 commit comments