Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ let package = Package(
.plugin(name: "BridgeJSCommandPlugin", targets: ["BridgeJSCommandPlugin"]),
],
dependencies: [
.package(url: "https://github.com/swiftlang/swift-syntax", "600.0.0"..<"601.0.0")
.package(url: "https://github.com/swiftlang/swift-syntax", "600.0.0"..<"603.0.0")
],
targets: [
.target(
Expand Down
11 changes: 11 additions & 0 deletions Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2528,9 +2528,20 @@ struct ClosureCodegen {
capture: ClosureCaptureClauseSyntax(
leftSquare: .leftSquareToken(),
items: ClosureCaptureListSyntax {
#if canImport(SwiftSyntax602)
ClosureCaptureSyntax(
name: .identifier("", presence: .missing), initializer: InitializerClauseSyntax(
equal: .equalToken(presence: .missing),
Comment thread
MaxDesiatov marked this conversation as resolved.
Outdated
nil,
value: ExprSyntax("callback")
),
trailingTrivia: nil
)
#else
ClosureCaptureSyntax(
expression: ExprSyntax("callback")
)
#endif
},
rightSquare: .rightSquareToken()
),
Expand Down
32 changes: 24 additions & 8 deletions Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -734,24 +734,40 @@ enum SwiftCodePattern {
/// Builds the standard @_expose and @_cdecl attributes for WebAssembly-exposed functions
static func buildExposeAttributes(abiName: String) -> AttributeListSyntax {
return AttributeListSyntax {
#if canImport(SwiftSyntax602)
let exposeAttrArgs = AttributeSyntax.Arguments.argumentList(
[
LabeledExprSyntax(label: nil, expression: DeclReferenceExprSyntax(baseName: "wasm")),
LabeledExprSyntax(label: nil, expression: StringLiteralExprSyntax(content: abiName)),
]
)
let cdeclAttrArgs = AttributeSyntax.Arguments.argumentList(
[
LabeledExprSyntax(label: nil, expression: StringLiteralExprSyntax(content: abiName)),
Comment thread
MaxDesiatov marked this conversation as resolved.
Outdated
]
)
#else
let exposeAttrArgs = AttributeSyntax.Arguments.exposeAttributeArguments(
ExposeAttributeArgumentsSyntax(
language: .identifier("wasm"),
comma: .commaToken(),
cxxName: StringLiteralExprSyntax(content: abiName)
)
)
let cdeclAttrArgs = AttributeSyntax.Arguments.string(StringLiteralExprSyntax(content: abiName))
#endif
AttributeSyntax(
attributeName: IdentifierTypeSyntax(name: .identifier("_expose")),
leftParen: .leftParenToken(),
arguments: .exposeAttributeArguments(
ExposeAttributeArgumentsSyntax(
language: .identifier("wasm"),
comma: .commaToken(),
cxxName: StringLiteralExprSyntax(content: abiName)
)
),
arguments: exposeAttrArgs,
rightParen: .rightParenToken()
)
.with(\.trailingTrivia, .newline)

AttributeSyntax(
attributeName: IdentifierTypeSyntax(name: .identifier("_cdecl")),
leftParen: .leftParenToken(),
arguments: .string(StringLiteralExprSyntax(content: abiName)),
arguments: cdeclAttrArgs,
rightParen: .rightParenToken()
)
.with(\.trailingTrivia, .newline)
Expand Down
Loading