Skip to content

Commit 22e7434

Browse files
BridgeJS: Remove reundant returnType from call family of methods in ImportedThunkBuilder
1 parent a03b585 commit 22e7434

File tree

1 file changed

+23
-46
lines changed

1 file changed

+23
-46
lines changed

Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift

Lines changed: 23 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ public struct BridgeJSLink {
755755
try thunkBuilder.liftParameter(param: Parameter(label: nil, name: paramName, type: paramType))
756756
}
757757

758-
try thunkBuilder.call(calleeExpr: "callback", returnType: signature.returnType)
758+
try thunkBuilder.call(calleeExpr: "callback")
759759

760760
var functionLines = thunkBuilder.renderFunction(name: nil)
761761
functionLines[0] = "bjs[\"\(functionName)\"] = " + functionLines[0]
@@ -2269,21 +2269,21 @@ extension BridgeJSLink {
22692269
return printer.lines
22702270
}
22712271

2272-
func call(name: String, fromObjectExpr: String, returnType: BridgeType) throws {
2272+
func call(name: String, fromObjectExpr: String) throws {
22732273
let calleeExpr = Self.propertyAccessExpr(objectExpr: fromObjectExpr, propertyName: name)
2274-
return try self.call(calleeExpr: calleeExpr, returnType: returnType)
2274+
return try self.call(calleeExpr: calleeExpr)
22752275
}
22762276

2277-
func call(name: String, returnType: BridgeType) throws {
2278-
return try call(name: name, fromObjectExpr: "imports", returnType: returnType)
2277+
func call(name: String) throws {
2278+
return try call(name: name, fromObjectExpr: "imports")
22792279
}
22802280

2281-
func call(calleeExpr: String, returnType: BridgeType) throws {
2281+
func call(calleeExpr: String) throws {
22822282
let callExpr = "\(calleeExpr)(\(parameterForwardings.joined(separator: ", ")))"
2283-
try self.call(callExpr: callExpr, returnType: returnType)
2283+
try self.call(callExpr: callExpr)
22842284
}
22852285

2286-
private func call(callExpr: String, returnType: BridgeType) throws {
2286+
private func call(callExpr: String) throws {
22872287
if effects.isAsync {
22882288
body.write("\(callExpr).then(resolve, reject);")
22892289
return
@@ -2321,13 +2321,10 @@ extension BridgeJSLink {
23212321
return try callConstructor(jsName: jsName, swiftTypeName: swiftTypeName, fromObjectExpr: "imports")
23222322
}
23232323

2324-
func callMethod(name: String, returnType: BridgeType) throws {
2324+
func callMethod(name: String) throws {
23252325
let objectExpr = "\(JSGlueVariableScope.reservedSwift).memory.getObject(self)"
23262326
let calleeExpr = Self.propertyAccessExpr(objectExpr: objectExpr, propertyName: name)
2327-
return try call(
2328-
calleeExpr: calleeExpr,
2329-
returnType: returnType
2330-
)
2327+
return try call(calleeExpr: calleeExpr)
23312328
}
23322329

23332330
/// Generates an async method call with resolve/reject closure refs.
@@ -2338,15 +2335,12 @@ extension BridgeJSLink {
23382335
body.write("\(callExpr).then(resolve, reject);")
23392336
}
23402337

2341-
func callStaticMethod(on objectExpr: String, name: String, returnType: BridgeType) throws {
2338+
func callStaticMethod(on objectExpr: String, name: String) throws {
23422339
let calleeExpr = Self.propertyAccessExpr(objectExpr: objectExpr, propertyName: name)
2343-
return try call(
2344-
calleeExpr: calleeExpr,
2345-
returnType: returnType
2346-
)
2340+
return try call(calleeExpr: calleeExpr)
23472341
}
23482342

2349-
func callPropertyGetter(name: String, returnType: BridgeType) throws {
2343+
func callPropertyGetter(name: String) throws {
23502344
let objectExpr = "\(JSGlueVariableScope.reservedSwift).memory.getObject(self)"
23512345
let accessExpr = Self.propertyAccessExpr(objectExpr: objectExpr, propertyName: name)
23522346
if context == .exportSwift, returnType.usesSideChannelForOptionalReturn() {
@@ -2366,13 +2360,10 @@ extension BridgeJSLink {
23662360
return
23672361
}
23682362

2369-
return try call(
2370-
callExpr: accessExpr,
2371-
returnType: returnType
2372-
)
2363+
return try call(callExpr: accessExpr)
23732364
}
23742365

2375-
func callPropertySetter(name: String, returnType: BridgeType) {
2366+
func callPropertySetter(name: String) {
23762367
let objectExpr = "\(JSGlueVariableScope.reservedSwift).memory.getObject(self)"
23772368
let accessExpr = Self.propertyAccessExpr(objectExpr: objectExpr, propertyName: name)
23782369
let call = "\(accessExpr) = \(parameterForwardings.joined(separator: ", "))"
@@ -3183,11 +3174,7 @@ extension BridgeJSLink {
31833174
let jsName = function.jsName ?? function.name
31843175
let importRootExpr = function.from == .global ? "globalThis" : "imports"
31853176

3186-
try thunkBuilder.call(
3187-
name: jsName,
3188-
fromObjectExpr: importRootExpr,
3189-
returnType: function.returnType
3190-
)
3177+
try thunkBuilder.call(name: jsName, fromObjectExpr: importRootExpr)
31913178
let funcLines = thunkBuilder.renderFunction(name: function.abiName(context: nil))
31923179
if function.from == nil {
31933180
importObjectBuilder.appendDts(
@@ -3240,10 +3227,7 @@ extension BridgeJSLink {
32403227
getter: getter,
32413228
abiName: getterAbiName,
32423229
emitCall: { thunkBuilder in
3243-
return try thunkBuilder.callPropertyGetter(
3244-
name: getter.jsName ?? getter.name,
3245-
returnType: getter.type
3246-
)
3230+
return try thunkBuilder.callPropertyGetter(name: getter.jsName ?? getter.name)
32473231
}
32483232
)
32493233
importObjectBuilder.assignToImportObject(name: getterAbiName, function: js)
@@ -3259,7 +3243,7 @@ extension BridgeJSLink {
32593243
try thunkBuilder.liftParameter(
32603244
param: Parameter(label: nil, name: "newValue", type: setter.type)
32613245
)
3262-
thunkBuilder.callPropertySetter(name: setter.jsName ?? setter.name, returnType: setter.type)
3246+
thunkBuilder.callPropertySetter(name: setter.jsName ?? setter.name)
32633247
}
32643248
)
32653249
importObjectBuilder.assignToImportObject(name: setterAbiName, function: js)
@@ -3372,11 +3356,7 @@ extension BridgeJSLink {
33723356
propertyName: context.jsName ?? context.name
33733357
)
33743358

3375-
try thunkBuilder.callStaticMethod(
3376-
on: constructorExpr,
3377-
name: method.jsName ?? method.name,
3378-
returnType: method.returnType
3379-
)
3359+
try thunkBuilder.callStaticMethod(on: constructorExpr, name: method.jsName ?? method.name)
33803360
let funcLines = thunkBuilder.renderFunction(name: method.abiName(context: context, operation: "static"))
33813361
return (funcLines, [])
33823362
}
@@ -3395,10 +3375,7 @@ extension BridgeJSLink {
33953375
try thunkBuilder.liftParameter(param: param)
33963376
}
33973377

3398-
try thunkBuilder.callMethod(
3399-
name: method.jsName ?? method.name,
3400-
returnType: method.returnType
3401-
)
3378+
try thunkBuilder.callMethod(name: method.jsName ?? method.name)
34023379
let funcLines = thunkBuilder.renderFunction(name: method.abiName(context: context))
34033380
return (funcLines, [])
34043381
}
@@ -3423,7 +3400,7 @@ extension BridgeJSLink {
34233400
intrinsicRegistry: intrinsicRegistry
34243401
)
34253402
getterThunkBuilder.liftSelf()
3426-
try getterThunkBuilder.callPropertyGetter(name: property.name, returnType: property.type)
3403+
try getterThunkBuilder.callPropertyGetter(name: property.name)
34273404
let getterLines = getterThunkBuilder.renderFunction(name: getterAbiName)
34283405
importObjectBuilder.assignToImportObject(name: getterAbiName, function: getterLines)
34293406

@@ -3445,7 +3422,7 @@ extension BridgeJSLink {
34453422
try setterThunkBuilder.liftParameter(
34463423
param: Parameter(label: nil, name: "value", type: property.type)
34473424
)
3448-
setterThunkBuilder.callPropertySetter(name: property.name, returnType: property.type)
3425+
setterThunkBuilder.callPropertySetter(name: property.name)
34493426
let setterLines = setterThunkBuilder.renderFunction(name: setterAbiName)
34503427
importObjectBuilder.assignToImportObject(name: setterAbiName, function: setterLines)
34513428
}
@@ -3466,7 +3443,7 @@ extension BridgeJSLink {
34663443
for param in method.parameters {
34673444
try thunkBuilder.liftParameter(param: param)
34683445
}
3469-
try thunkBuilder.callMethod(name: method.name, returnType: method.returnType)
3446+
try thunkBuilder.callMethod(name: method.name)
34703447
let funcLines = thunkBuilder.renderFunction(name: method.abiName)
34713448
importObjectBuilder.assignToImportObject(name: method.abiName, function: funcLines)
34723449
}

0 commit comments

Comments
 (0)