Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
45 changes: 15 additions & 30 deletions Benchmarks/Sources/Generated/BridgeJS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,7 @@ extension SimpleStruct: _BridgedSwiftStruct {
}

init(unsafelyCopying jsObject: JSObject) {
let __bjs_cleanupId = _bjs_struct_lower_SimpleStruct(jsObject.bridgeJSLowerParameter())
defer {
_swift_js_struct_cleanup(__bjs_cleanupId)
}
_bjs_struct_lower_SimpleStruct(jsObject.bridgeJSLowerParameter())
self = Self.bridgeJSStackPop()
}

Expand All @@ -148,9 +145,9 @@ extension SimpleStruct: _BridgedSwiftStruct {

#if arch(wasm32)
@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_SimpleStruct")
fileprivate func _bjs_struct_lower_SimpleStruct(_ objectId: Int32) -> Int32
fileprivate func _bjs_struct_lower_SimpleStruct(_ objectId: Int32) -> Void
#else
fileprivate func _bjs_struct_lower_SimpleStruct(_ objectId: Int32) -> Int32 {
fileprivate func _bjs_struct_lower_SimpleStruct(_ objectId: Int32) -> Void {
fatalError("Only available on WebAssembly")
}
#endif
Expand Down Expand Up @@ -179,10 +176,7 @@ extension Address: _BridgedSwiftStruct {
}

init(unsafelyCopying jsObject: JSObject) {
let __bjs_cleanupId = _bjs_struct_lower_Address(jsObject.bridgeJSLowerParameter())
defer {
_swift_js_struct_cleanup(__bjs_cleanupId)
}
_bjs_struct_lower_Address(jsObject.bridgeJSLowerParameter())
self = Self.bridgeJSStackPop()
}

Expand All @@ -195,9 +189,9 @@ extension Address: _BridgedSwiftStruct {

#if arch(wasm32)
@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Address")
fileprivate func _bjs_struct_lower_Address(_ objectId: Int32) -> Int32
fileprivate func _bjs_struct_lower_Address(_ objectId: Int32) -> Void
#else
fileprivate func _bjs_struct_lower_Address(_ objectId: Int32) -> Int32 {
fileprivate func _bjs_struct_lower_Address(_ objectId: Int32) -> Void {
fatalError("Only available on WebAssembly")
}
#endif
Expand Down Expand Up @@ -232,10 +226,7 @@ extension Person: _BridgedSwiftStruct {
}

init(unsafelyCopying jsObject: JSObject) {
let __bjs_cleanupId = _bjs_struct_lower_Person(jsObject.bridgeJSLowerParameter())
defer {
_swift_js_struct_cleanup(__bjs_cleanupId)
}
_bjs_struct_lower_Person(jsObject.bridgeJSLowerParameter())
self = Self.bridgeJSStackPop()
}

Expand All @@ -248,9 +239,9 @@ extension Person: _BridgedSwiftStruct {

#if arch(wasm32)
@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Person")
fileprivate func _bjs_struct_lower_Person(_ objectId: Int32) -> Int32
fileprivate func _bjs_struct_lower_Person(_ objectId: Int32) -> Void
#else
fileprivate func _bjs_struct_lower_Person(_ objectId: Int32) -> Int32 {
fileprivate func _bjs_struct_lower_Person(_ objectId: Int32) -> Void {
fatalError("Only available on WebAssembly")
}
#endif
Expand Down Expand Up @@ -285,10 +276,7 @@ extension ComplexStruct: _BridgedSwiftStruct {
}

init(unsafelyCopying jsObject: JSObject) {
let __bjs_cleanupId = _bjs_struct_lower_ComplexStruct(jsObject.bridgeJSLowerParameter())
defer {
_swift_js_struct_cleanup(__bjs_cleanupId)
}
_bjs_struct_lower_ComplexStruct(jsObject.bridgeJSLowerParameter())
self = Self.bridgeJSStackPop()
}

Expand All @@ -301,9 +289,9 @@ extension ComplexStruct: _BridgedSwiftStruct {

#if arch(wasm32)
@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_ComplexStruct")
fileprivate func _bjs_struct_lower_ComplexStruct(_ objectId: Int32) -> Int32
fileprivate func _bjs_struct_lower_ComplexStruct(_ objectId: Int32) -> Void
#else
fileprivate func _bjs_struct_lower_ComplexStruct(_ objectId: Int32) -> Int32 {
fileprivate func _bjs_struct_lower_ComplexStruct(_ objectId: Int32) -> Void {
fatalError("Only available on WebAssembly")
}
#endif
Expand All @@ -330,10 +318,7 @@ extension Point: _BridgedSwiftStruct {
}

init(unsafelyCopying jsObject: JSObject) {
let __bjs_cleanupId = _bjs_struct_lower_Point(jsObject.bridgeJSLowerParameter())
defer {
_swift_js_struct_cleanup(__bjs_cleanupId)
}
_bjs_struct_lower_Point(jsObject.bridgeJSLowerParameter())
self = Self.bridgeJSStackPop()
}

Expand All @@ -346,9 +331,9 @@ extension Point: _BridgedSwiftStruct {

#if arch(wasm32)
@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Point")
fileprivate func _bjs_struct_lower_Point(_ objectId: Int32) -> Int32
fileprivate func _bjs_struct_lower_Point(_ objectId: Int32) -> Void
#else
fileprivate func _bjs_struct_lower_Point(_ objectId: Int32) -> Int32 {
fileprivate func _bjs_struct_lower_Point(_ objectId: Int32) -> Void {
fatalError("Only available on WebAssembly")
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ extension PlayBridgeJSOutput: _BridgedSwiftStruct {
}

init(unsafelyCopying jsObject: JSObject) {
let __bjs_cleanupId = _bjs_struct_lower_PlayBridgeJSOutput(jsObject.bridgeJSLowerParameter())
defer {
_swift_js_struct_cleanup(__bjs_cleanupId)
}
_bjs_struct_lower_PlayBridgeJSOutput(jsObject.bridgeJSLowerParameter())
self = Self.bridgeJSStackPop()
}

Expand All @@ -40,9 +37,9 @@ extension PlayBridgeJSOutput: _BridgedSwiftStruct {

#if arch(wasm32)
@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_PlayBridgeJSOutput")
fileprivate func _bjs_struct_lower_PlayBridgeJSOutput(_ objectId: Int32) -> Int32
fileprivate func _bjs_struct_lower_PlayBridgeJSOutput(_ objectId: Int32) -> Void
#else
fileprivate func _bjs_struct_lower_PlayBridgeJSOutput(_ objectId: Int32) -> Int32 {
fileprivate func _bjs_struct_lower_PlayBridgeJSOutput(_ objectId: Int32) -> Void {
fatalError("Only available on WebAssembly")
}
#endif
Expand Down Expand Up @@ -77,10 +74,7 @@ extension PlayBridgeJSDiagnostic: _BridgedSwiftStruct {
}

init(unsafelyCopying jsObject: JSObject) {
let __bjs_cleanupId = _bjs_struct_lower_PlayBridgeJSDiagnostic(jsObject.bridgeJSLowerParameter())
defer {
_swift_js_struct_cleanup(__bjs_cleanupId)
}
_bjs_struct_lower_PlayBridgeJSDiagnostic(jsObject.bridgeJSLowerParameter())
self = Self.bridgeJSStackPop()
}

Expand All @@ -93,9 +87,9 @@ extension PlayBridgeJSDiagnostic: _BridgedSwiftStruct {

#if arch(wasm32)
@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_PlayBridgeJSDiagnostic")
fileprivate func _bjs_struct_lower_PlayBridgeJSDiagnostic(_ objectId: Int32) -> Int32
fileprivate func _bjs_struct_lower_PlayBridgeJSDiagnostic(_ objectId: Int32) -> Void
#else
fileprivate func _bjs_struct_lower_PlayBridgeJSDiagnostic(_ objectId: Int32) -> Int32 {
fileprivate func _bjs_struct_lower_PlayBridgeJSDiagnostic(_ objectId: Int32) -> Void {
fatalError("Only available on WebAssembly")
}
#endif
Expand All @@ -122,10 +116,7 @@ extension PlayBridgeJSResult: _BridgedSwiftStruct {
}

init(unsafelyCopying jsObject: JSObject) {
let __bjs_cleanupId = _bjs_struct_lower_PlayBridgeJSResult(jsObject.bridgeJSLowerParameter())
defer {
_swift_js_struct_cleanup(__bjs_cleanupId)
}
_bjs_struct_lower_PlayBridgeJSResult(jsObject.bridgeJSLowerParameter())
self = Self.bridgeJSStackPop()
}

Expand All @@ -138,9 +129,9 @@ extension PlayBridgeJSResult: _BridgedSwiftStruct {

#if arch(wasm32)
@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_PlayBridgeJSResult")
fileprivate func _bjs_struct_lower_PlayBridgeJSResult(_ objectId: Int32) -> Int32
fileprivate func _bjs_struct_lower_PlayBridgeJSResult(_ objectId: Int32) -> Void
#else
fileprivate func _bjs_struct_lower_PlayBridgeJSResult(_ objectId: Int32) -> Int32 {
fileprivate func _bjs_struct_lower_PlayBridgeJSResult(_ objectId: Int32) -> Void {
fatalError("Only available on WebAssembly")
}
#endif
Expand Down
12 changes: 6 additions & 6 deletions Plugins/BridgeJS/Sources/BridgeJSCore/ClosureCodegen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,23 +123,23 @@ public struct ClosureCodegen {

for (index, paramType) in signature.parameters.enumerated() {
let paramName = "param\(index)"
let liftInfo = try paramType.liftParameterInfo()
let liftParams = try paramType.liftParameterInfo()

for (argName, wasmType) in liftInfo.parameters {
for (argName, wasmType) in liftParams {
let fullName =
liftInfo.parameters.count > 1 ? "\(paramName)\(argName.capitalizedFirstLetter)" : paramName
liftParams.count > 1 ? "\(paramName)\(argName.capitalizedFirstLetter)" : paramName
abiParams.append((fullName, wasmType))
}

let argNames = liftInfo.parameters.map { (argName, _) in
liftInfo.parameters.count > 1 ? "\(paramName)\(argName.capitalizedFirstLetter)" : paramName
let argNames = liftParams.map { (argName, _) in
liftParams.count > 1 ? "\(paramName)\(argName.capitalizedFirstLetter)" : paramName
}
liftedParams.append("\(paramType.swiftType).bridgeJSLiftParameter(\(argNames.joined(separator: ", ")))")
}

let closureCallExpr = ExprSyntax("closure(\(raw: liftedParams.joined(separator: ", ")))")

let abiReturnWasmType = try signature.returnType.loweringReturnInfo().returnType
let abiReturnWasmType = try signature.returnType.loweringReturnInfo()

// Build signature using SwiftSignatureBuilder
let funcSignature = SwiftSignatureBuilder.buildABIFunctionSignature(
Expand Down
Loading