Skip to content

Commit 052a273

Browse files
BridgeJSLink: remove cleanup hooks
2 parents 11eb81c + 0a0a580 commit 052a273

File tree

9 files changed

+44
-90
lines changed

9 files changed

+44
-90
lines changed

Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,10 +1243,7 @@ struct StructCodegen {
12431243
printer.write(
12441244
multilineString: """
12451245
\(accessControl)init(unsafelyCopying jsObject: JSObject) {
1246-
let __bjs_cleanupId = \(lowerFunctionName)(jsObject.bridgeJSLowerParameter())
1247-
defer {
1248-
_swift_js_struct_cleanup(__bjs_cleanupId)
1249-
}
1246+
\(lowerFunctionName)(jsObject.bridgeJSLowerParameter())
12501247
self = Self.bridgeJSStackPop()
12511248
}
12521249
"""
@@ -1274,7 +1271,7 @@ struct StructCodegen {
12741271
functionName: lowerFunctionName,
12751272
signature: SwiftSignatureBuilder.buildABIFunctionSignature(
12761273
abiParameters: [("objectId", .i32)],
1277-
returnType: .i32
1274+
returnType: nil
12781275
)
12791276
)
12801277
let liftExternDeclPrinter = CodeFragmentPrinter()

Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,6 @@ public struct BridgeJSLink {
399399
printer.write(
400400
"\(JSGlueVariableScope.reservedStructHelpers).\(structDef.name).lower(\(JSGlueVariableScope.reservedSwift).memory.getObject(objectId));"
401401
)
402-
printer.write("return 0;")
403402
}
404403
printer.write("}")
405404

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ArrayTypes.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,7 @@ extension Point: _BridgedSwiftStruct {
5757
}
5858

5959
init(unsafelyCopying jsObject: JSObject) {
60-
let __bjs_cleanupId = _bjs_struct_lower_Point(jsObject.bridgeJSLowerParameter())
61-
defer {
62-
_swift_js_struct_cleanup(__bjs_cleanupId)
63-
}
60+
_bjs_struct_lower_Point(jsObject.bridgeJSLowerParameter())
6461
self = Self.bridgeJSStackPop()
6562
}
6663

@@ -73,9 +70,9 @@ extension Point: _BridgedSwiftStruct {
7370

7471
#if arch(wasm32)
7572
@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Point")
76-
fileprivate func _bjs_struct_lower_Point(_ objectId: Int32) -> Int32
73+
fileprivate func _bjs_struct_lower_Point(_ objectId: Int32) -> Void
7774
#else
78-
fileprivate func _bjs_struct_lower_Point(_ objectId: Int32) -> Int32 {
75+
fileprivate func _bjs_struct_lower_Point(_ objectId: Int32) -> Void {
7976
fatalError("Only available on WebAssembly")
8077
}
8178
#endif

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/DefaultParameters.swift

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ extension Config: _BridgedSwiftStruct {
5252
}
5353

5454
init(unsafelyCopying jsObject: JSObject) {
55-
let __bjs_cleanupId = _bjs_struct_lower_Config(jsObject.bridgeJSLowerParameter())
56-
defer {
57-
_swift_js_struct_cleanup(__bjs_cleanupId)
58-
}
55+
_bjs_struct_lower_Config(jsObject.bridgeJSLowerParameter())
5956
self = Self.bridgeJSStackPop()
6057
}
6158

@@ -68,9 +65,9 @@ extension Config: _BridgedSwiftStruct {
6865

6966
#if arch(wasm32)
7067
@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Config")
71-
fileprivate func _bjs_struct_lower_Config(_ objectId: Int32) -> Int32
68+
fileprivate func _bjs_struct_lower_Config(_ objectId: Int32) -> Void
7269
#else
73-
fileprivate func _bjs_struct_lower_Config(_ objectId: Int32) -> Int32 {
70+
fileprivate func _bjs_struct_lower_Config(_ objectId: Int32) -> Void {
7471
fatalError("Only available on WebAssembly")
7572
}
7673
#endif
@@ -95,10 +92,7 @@ extension MathOperations: _BridgedSwiftStruct {
9592
}
9693

9794
init(unsafelyCopying jsObject: JSObject) {
98-
let __bjs_cleanupId = _bjs_struct_lower_MathOperations(jsObject.bridgeJSLowerParameter())
99-
defer {
100-
_swift_js_struct_cleanup(__bjs_cleanupId)
101-
}
95+
_bjs_struct_lower_MathOperations(jsObject.bridgeJSLowerParameter())
10296
self = Self.bridgeJSStackPop()
10397
}
10498

@@ -111,9 +105,9 @@ extension MathOperations: _BridgedSwiftStruct {
111105

112106
#if arch(wasm32)
113107
@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_MathOperations")
114-
fileprivate func _bjs_struct_lower_MathOperations(_ objectId: Int32) -> Int32
108+
fileprivate func _bjs_struct_lower_MathOperations(_ objectId: Int32) -> Void
115109
#else
116-
fileprivate func _bjs_struct_lower_MathOperations(_ objectId: Int32) -> Int32 {
110+
fileprivate func _bjs_struct_lower_MathOperations(_ objectId: Int32) -> Void {
117111
fatalError("Only available on WebAssembly")
118112
}
119113
#endif

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/EnumAssociatedValue.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,7 @@ extension Point: _BridgedSwiftStruct {
413413
}
414414

415415
init(unsafelyCopying jsObject: JSObject) {
416-
let __bjs_cleanupId = _bjs_struct_lower_Point(jsObject.bridgeJSLowerParameter())
417-
defer {
418-
_swift_js_struct_cleanup(__bjs_cleanupId)
419-
}
416+
_bjs_struct_lower_Point(jsObject.bridgeJSLowerParameter())
420417
self = Self.bridgeJSStackPop()
421418
}
422419

@@ -429,9 +426,9 @@ extension Point: _BridgedSwiftStruct {
429426

430427
#if arch(wasm32)
431428
@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Point")
432-
fileprivate func _bjs_struct_lower_Point(_ objectId: Int32) -> Int32
429+
fileprivate func _bjs_struct_lower_Point(_ objectId: Int32) -> Void
433430
#else
434-
fileprivate func _bjs_struct_lower_Point(_ objectId: Int32) -> Int32 {
431+
fileprivate func _bjs_struct_lower_Point(_ objectId: Int32) -> Void {
435432
fatalError("Only available on WebAssembly")
436433
}
437434
#endif

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/ImportedTypeInExportedInterface.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ extension FooContainer: _BridgedSwiftStruct {
1515
}
1616

1717
init(unsafelyCopying jsObject: JSObject) {
18-
let __bjs_cleanupId = _bjs_struct_lower_FooContainer(jsObject.bridgeJSLowerParameter())
19-
defer {
20-
_swift_js_struct_cleanup(__bjs_cleanupId)
21-
}
18+
_bjs_struct_lower_FooContainer(jsObject.bridgeJSLowerParameter())
2219
self = Self.bridgeJSStackPop()
2320
}
2421

@@ -31,9 +28,9 @@ extension FooContainer: _BridgedSwiftStruct {
3128

3229
#if arch(wasm32)
3330
@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_FooContainer")
34-
fileprivate func _bjs_struct_lower_FooContainer(_ objectId: Int32) -> Int32
31+
fileprivate func _bjs_struct_lower_FooContainer(_ objectId: Int32) -> Void
3532
#else
36-
fileprivate func _bjs_struct_lower_FooContainer(_ objectId: Int32) -> Int32 {
33+
fileprivate func _bjs_struct_lower_FooContainer(_ objectId: Int32) -> Void {
3734
fatalError("Only available on WebAssembly")
3835
}
3936
#endif

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftStruct.swift

Lines changed: 21 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ extension DataPoint: _BridgedSwiftStruct {
2828
}
2929

3030
init(unsafelyCopying jsObject: JSObject) {
31-
let __bjs_cleanupId = _bjs_struct_lower_DataPoint(jsObject.bridgeJSLowerParameter())
32-
defer {
33-
_swift_js_struct_cleanup(__bjs_cleanupId)
34-
}
31+
_bjs_struct_lower_DataPoint(jsObject.bridgeJSLowerParameter())
3532
self = Self.bridgeJSStackPop()
3633
}
3734

@@ -44,9 +41,9 @@ extension DataPoint: _BridgedSwiftStruct {
4441

4542
#if arch(wasm32)
4643
@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_DataPoint")
47-
fileprivate func _bjs_struct_lower_DataPoint(_ objectId: Int32) -> Int32
44+
fileprivate func _bjs_struct_lower_DataPoint(_ objectId: Int32) -> Void
4845
#else
49-
fileprivate func _bjs_struct_lower_DataPoint(_ objectId: Int32) -> Int32 {
46+
fileprivate func _bjs_struct_lower_DataPoint(_ objectId: Int32) -> Void {
5047
fatalError("Only available on WebAssembly")
5148
}
5249
#endif
@@ -90,10 +87,7 @@ extension Address: _BridgedSwiftStruct {
9087
}
9188

9289
init(unsafelyCopying jsObject: JSObject) {
93-
let __bjs_cleanupId = _bjs_struct_lower_Address(jsObject.bridgeJSLowerParameter())
94-
defer {
95-
_swift_js_struct_cleanup(__bjs_cleanupId)
96-
}
90+
_bjs_struct_lower_Address(jsObject.bridgeJSLowerParameter())
9791
self = Self.bridgeJSStackPop()
9892
}
9993

@@ -106,9 +100,9 @@ extension Address: _BridgedSwiftStruct {
106100

107101
#if arch(wasm32)
108102
@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Address")
109-
fileprivate func _bjs_struct_lower_Address(_ objectId: Int32) -> Int32
103+
fileprivate func _bjs_struct_lower_Address(_ objectId: Int32) -> Void
110104
#else
111-
fileprivate func _bjs_struct_lower_Address(_ objectId: Int32) -> Int32 {
105+
fileprivate func _bjs_struct_lower_Address(_ objectId: Int32) -> Void {
112106
fatalError("Only available on WebAssembly")
113107
}
114108
#endif
@@ -143,10 +137,7 @@ extension Person: _BridgedSwiftStruct {
143137
}
144138

145139
init(unsafelyCopying jsObject: JSObject) {
146-
let __bjs_cleanupId = _bjs_struct_lower_Person(jsObject.bridgeJSLowerParameter())
147-
defer {
148-
_swift_js_struct_cleanup(__bjs_cleanupId)
149-
}
140+
_bjs_struct_lower_Person(jsObject.bridgeJSLowerParameter())
150141
self = Self.bridgeJSStackPop()
151142
}
152143

@@ -159,9 +150,9 @@ extension Person: _BridgedSwiftStruct {
159150

160151
#if arch(wasm32)
161152
@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Person")
162-
fileprivate func _bjs_struct_lower_Person(_ objectId: Int32) -> Int32
153+
fileprivate func _bjs_struct_lower_Person(_ objectId: Int32) -> Void
163154
#else
164-
fileprivate func _bjs_struct_lower_Person(_ objectId: Int32) -> Int32 {
155+
fileprivate func _bjs_struct_lower_Person(_ objectId: Int32) -> Void {
165156
fatalError("Only available on WebAssembly")
166157
}
167158
#endif
@@ -188,10 +179,7 @@ extension Session: _BridgedSwiftStruct {
188179
}
189180

190181
init(unsafelyCopying jsObject: JSObject) {
191-
let __bjs_cleanupId = _bjs_struct_lower_Session(jsObject.bridgeJSLowerParameter())
192-
defer {
193-
_swift_js_struct_cleanup(__bjs_cleanupId)
194-
}
182+
_bjs_struct_lower_Session(jsObject.bridgeJSLowerParameter())
195183
self = Self.bridgeJSStackPop()
196184
}
197185

@@ -204,9 +192,9 @@ extension Session: _BridgedSwiftStruct {
204192

205193
#if arch(wasm32)
206194
@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Session")
207-
fileprivate func _bjs_struct_lower_Session(_ objectId: Int32) -> Int32
195+
fileprivate func _bjs_struct_lower_Session(_ objectId: Int32) -> Void
208196
#else
209-
fileprivate func _bjs_struct_lower_Session(_ objectId: Int32) -> Int32 {
197+
fileprivate func _bjs_struct_lower_Session(_ objectId: Int32) -> Void {
210198
fatalError("Only available on WebAssembly")
211199
}
212200
#endif
@@ -239,10 +227,7 @@ extension Measurement: _BridgedSwiftStruct {
239227
}
240228

241229
init(unsafelyCopying jsObject: JSObject) {
242-
let __bjs_cleanupId = _bjs_struct_lower_Measurement(jsObject.bridgeJSLowerParameter())
243-
defer {
244-
_swift_js_struct_cleanup(__bjs_cleanupId)
245-
}
230+
_bjs_struct_lower_Measurement(jsObject.bridgeJSLowerParameter())
246231
self = Self.bridgeJSStackPop()
247232
}
248233

@@ -255,9 +240,9 @@ extension Measurement: _BridgedSwiftStruct {
255240

256241
#if arch(wasm32)
257242
@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Measurement")
258-
fileprivate func _bjs_struct_lower_Measurement(_ objectId: Int32) -> Int32
243+
fileprivate func _bjs_struct_lower_Measurement(_ objectId: Int32) -> Void
259244
#else
260-
fileprivate func _bjs_struct_lower_Measurement(_ objectId: Int32) -> Int32 {
245+
fileprivate func _bjs_struct_lower_Measurement(_ objectId: Int32) -> Void {
261246
fatalError("Only available on WebAssembly")
262247
}
263248
#endif
@@ -280,10 +265,7 @@ extension ConfigStruct: _BridgedSwiftStruct {
280265
}
281266

282267
init(unsafelyCopying jsObject: JSObject) {
283-
let __bjs_cleanupId = _bjs_struct_lower_ConfigStruct(jsObject.bridgeJSLowerParameter())
284-
defer {
285-
_swift_js_struct_cleanup(__bjs_cleanupId)
286-
}
268+
_bjs_struct_lower_ConfigStruct(jsObject.bridgeJSLowerParameter())
287269
self = Self.bridgeJSStackPop()
288270
}
289271

@@ -296,9 +278,9 @@ extension ConfigStruct: _BridgedSwiftStruct {
296278

297279
#if arch(wasm32)
298280
@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_ConfigStruct")
299-
fileprivate func _bjs_struct_lower_ConfigStruct(_ objectId: Int32) -> Int32
281+
fileprivate func _bjs_struct_lower_ConfigStruct(_ objectId: Int32) -> Void
300282
#else
301-
fileprivate func _bjs_struct_lower_ConfigStruct(_ objectId: Int32) -> Int32 {
283+
fileprivate func _bjs_struct_lower_ConfigStruct(_ objectId: Int32) -> Void {
302284
fatalError("Only available on WebAssembly")
303285
}
304286
#endif
@@ -404,10 +386,7 @@ extension Container: _BridgedSwiftStruct {
404386
}
405387

406388
init(unsafelyCopying jsObject: JSObject) {
407-
let __bjs_cleanupId = _bjs_struct_lower_Container(jsObject.bridgeJSLowerParameter())
408-
defer {
409-
_swift_js_struct_cleanup(__bjs_cleanupId)
410-
}
389+
_bjs_struct_lower_Container(jsObject.bridgeJSLowerParameter())
411390
self = Self.bridgeJSStackPop()
412391
}
413392

@@ -420,9 +399,9 @@ extension Container: _BridgedSwiftStruct {
420399

421400
#if arch(wasm32)
422401
@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Container")
423-
fileprivate func _bjs_struct_lower_Container(_ objectId: Int32) -> Int32
402+
fileprivate func _bjs_struct_lower_Container(_ objectId: Int32) -> Void
424403
#else
425-
fileprivate func _bjs_struct_lower_Container(_ objectId: Int32) -> Int32 {
404+
fileprivate func _bjs_struct_lower_Container(_ objectId: Int32) -> Void {
426405
fatalError("Only available on WebAssembly")
427406
}
428407
#endif

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/SwiftStructImports.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ extension Point: _BridgedSwiftStruct {
1111
}
1212

1313
init(unsafelyCopying jsObject: JSObject) {
14-
let __bjs_cleanupId = _bjs_struct_lower_Point(jsObject.bridgeJSLowerParameter())
15-
defer {
16-
_swift_js_struct_cleanup(__bjs_cleanupId)
17-
}
14+
_bjs_struct_lower_Point(jsObject.bridgeJSLowerParameter())
1815
self = Self.bridgeJSStackPop()
1916
}
2017

@@ -27,9 +24,9 @@ extension Point: _BridgedSwiftStruct {
2724

2825
#if arch(wasm32)
2926
@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_Point")
30-
fileprivate func _bjs_struct_lower_Point(_ objectId: Int32) -> Int32
27+
fileprivate func _bjs_struct_lower_Point(_ objectId: Int32) -> Void
3128
#else
32-
fileprivate func _bjs_struct_lower_Point(_ objectId: Int32) -> Int32 {
29+
fileprivate func _bjs_struct_lower_Point(_ objectId: Int32) -> Void {
3330
fatalError("Only available on WebAssembly")
3431
}
3532
#endif

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/UnsafePointer.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ extension PointerFields: _BridgedSwiftStruct {
1717
}
1818

1919
init(unsafelyCopying jsObject: JSObject) {
20-
let __bjs_cleanupId = _bjs_struct_lower_PointerFields(jsObject.bridgeJSLowerParameter())
21-
defer {
22-
_swift_js_struct_cleanup(__bjs_cleanupId)
23-
}
20+
_bjs_struct_lower_PointerFields(jsObject.bridgeJSLowerParameter())
2421
self = Self.bridgeJSStackPop()
2522
}
2623

@@ -33,9 +30,9 @@ extension PointerFields: _BridgedSwiftStruct {
3330

3431
#if arch(wasm32)
3532
@_extern(wasm, module: "bjs", name: "swift_js_struct_lower_PointerFields")
36-
fileprivate func _bjs_struct_lower_PointerFields(_ objectId: Int32) -> Int32
33+
fileprivate func _bjs_struct_lower_PointerFields(_ objectId: Int32) -> Void
3734
#else
38-
fileprivate func _bjs_struct_lower_PointerFields(_ objectId: Int32) -> Int32 {
35+
fileprivate func _bjs_struct_lower_PointerFields(_ objectId: Int32) -> Void {
3936
fatalError("Only available on WebAssembly")
4037
}
4138
#endif

0 commit comments

Comments
 (0)