Skip to content

Commit dadff8b

Browse files
authored
NFC: BridgeJS: Reduce retained object cleanup warning noise in BridgeJS glue (#633)
1 parent 83995af commit dadff8b

File tree

3 files changed

+3
-51
lines changed

3 files changed

+3
-51
lines changed

Plugins/BridgeJS/Sources/BridgeJSLink/JSGlueGen.swift

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3026,7 +3026,7 @@ struct IntrinsicJSFragment: Sendable {
30263026
return IntrinsicJSFragment(
30273027
parameters: ["value"],
30283028
printCode: { arguments, context in
3029-
let (scope, printer, cleanup) = (context.scope, context.printer, context.cleanupCode)
3029+
let (scope, printer) = (context.scope, context.printer)
30303030
let value = arguments[0]
30313031
let idVar = scope.variable("id")
30323032
printer.write("let \(idVar);")
@@ -3040,16 +3040,6 @@ struct IntrinsicJSFragment: Sendable {
30403040
}
30413041
printer.write("}")
30423042
scope.emitPushI32Parameter("\(idVar) !== undefined ? \(idVar) : 0", printer: printer)
3043-
cleanup.write("if(\(idVar) !== undefined && \(idVar) !== 0) {")
3044-
cleanup.indent {
3045-
cleanup.write("try {")
3046-
cleanup.indent {
3047-
cleanup.write("\(JSGlueVariableScope.reservedSwift).memory.getObject(\(idVar));")
3048-
cleanup.write("\(JSGlueVariableScope.reservedSwift).memory.release(\(idVar));")
3049-
}
3050-
cleanup.write("} catch(e) {}")
3051-
}
3052-
cleanup.write("}")
30533043
return [idVar]
30543044
}
30553045
)
@@ -3208,16 +3198,6 @@ struct IntrinsicJSFragment: Sendable {
32083198
}
32093199
printer.write("}")
32103200
scope.emitPushI32Parameter("\(isSomeVar) ? 1 : 0", printer: printer)
3211-
cleanup.write("if(\(idVar) !== undefined && \(idVar) !== 0) {")
3212-
cleanup.indent {
3213-
cleanup.write("try {")
3214-
cleanup.indent {
3215-
cleanup.write("\(JSGlueVariableScope.reservedSwift).memory.getObject(\(idVar));")
3216-
cleanup.write("\(JSGlueVariableScope.reservedSwift).memory.release(\(idVar));")
3217-
}
3218-
cleanup.write("} catch(e) {}")
3219-
}
3220-
cleanup.write("}")
32213201
return [idVar]
32223202
} else {
32233203
switch wrappedType {

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ImportedTypeInExportedInterface.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,7 @@ export async function createInstantiator(options, swift) {
4949
i32Stack.push(0);
5050
}
5151
i32Stack.push(isSome ? 1 : 0);
52-
const cleanup = () => {
53-
if(id !== undefined && id !== 0) {
54-
try {
55-
swift.memory.getObject(id);
56-
swift.memory.release(id);
57-
} catch(e) {}
58-
}
59-
if(id1 !== undefined && id1 !== 0) {
60-
try {
61-
swift.memory.getObject(id1);
62-
swift.memory.release(id1);
63-
} catch(e) {}
64-
}
65-
};
66-
return { cleanup };
52+
return { cleanup: undefined };
6753
},
6854
lift: () => {
6955
const isSome = i32Stack.pop();

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftStruct.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -243,21 +243,7 @@ export async function createInstantiator(options, swift) {
243243
i32Stack.push(0);
244244
}
245245
i32Stack.push(isSome ? 1 : 0);
246-
const cleanup = () => {
247-
if(id !== undefined && id !== 0) {
248-
try {
249-
swift.memory.getObject(id);
250-
swift.memory.release(id);
251-
} catch(e) {}
252-
}
253-
if(id1 !== undefined && id1 !== 0) {
254-
try {
255-
swift.memory.getObject(id1);
256-
swift.memory.release(id1);
257-
} catch(e) {}
258-
}
259-
};
260-
return { cleanup };
246+
return { cleanup: undefined };
261247
},
262248
lift: () => {
263249
const isSome = i32Stack.pop();

0 commit comments

Comments
 (0)