Skip to content

Commit ca567cf

Browse files
committed
BridgeJS: Rename _BridgedSwiftGenericBridgeable to BridgedSwiftGenericBridgeable
1 parent 50bcb2c commit ca567cf

20 files changed

Lines changed: 326 additions & 326 deletions

File tree

Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ struct GenericExportCodegen {
944944

945945
func renderConformance(typeName: String, abiName: String) -> [DeclSyntax] {
946946
let printer = CodeFragmentPrinter()
947-
printer.write("extension \(typeName): _BridgedSwiftGenericBridgeable {")
947+
printer.write("extension \(typeName): BridgedSwiftGenericBridgeable {")
948948
printer.indent {
949949
printer.write(
950950
"@_spi(BridgeJS) public static let bridgeJSTypeID: Int32 = _swift_js_resolve_type_id(\"\(abiName)\")"
@@ -958,11 +958,11 @@ struct GenericExportCodegen {
958958
let printer = CodeFragmentPrinter()
959959
printer.write("#if !hasFeature(Embedded)")
960960
printer.write(
961-
"private let _bridgeJSExportTypeRegistry: [Int32: any _BridgedSwiftGenericBridgeable.Type] = {"
961+
"private let _bridgeJSExportTypeRegistry: [Int32: any BridgedSwiftGenericBridgeable.Type] = {"
962962
)
963963
printer.indent {
964-
printer.write("var registry: [Int32: any _BridgedSwiftGenericBridgeable.Type] = [:]")
965-
printer.write("func register<T: _BridgedSwiftGenericBridgeable>(_ type: T.Type) {")
964+
printer.write("var registry: [Int32: any BridgedSwiftGenericBridgeable.Type] = [:]")
965+
printer.write("func register<T: BridgedSwiftGenericBridgeable>(_ type: T.Type) {")
966966
printer.indent {
967967
printer.write("registry[T.bridgeJSTypeID] = type")
968968
}
@@ -1116,15 +1116,15 @@ struct GenericExportCodegen {
11161116

11171117
let genericClauseNames = [openedName] + alreadyOpened
11181118
let genericClause =
1119-
"<\(genericClauseNames.map { "\($0): _BridgedSwiftGenericBridgeable" }.joined(separator: ", "))>"
1119+
"<\(genericClauseNames.map { "\($0): BridgedSwiftGenericBridgeable" }.joined(separator: ", "))>"
11201120

11211121
var params: [String] = []
11221122
params.append("_ \(metatypeName(openedName)): \(openedName).Type")
11231123
for openedAlready in alreadyOpened {
11241124
params.append("as\(openedAlready) \(metatypeName(openedAlready)): \(openedAlready).Type")
11251125
}
11261126
for remainingName in remaining {
1127-
params.append("_ \(metatypeName(remainingName)): any _BridgedSwiftGenericBridgeable.Type")
1127+
params.append("_ \(metatypeName(remainingName)): any BridgedSwiftGenericBridgeable.Type")
11281128
}
11291129
for abiParam in concreteABIParameters {
11301130
params.append("_ \(abiParam.name): \(abiParam.type.swiftType)")

Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ public struct ImportTS {
397397
let genericClause =
398398
genericParameters.isEmpty
399399
? ""
400-
: "<" + genericParameters.map { "\($0): _BridgedSwiftGenericBridgeable" }.joined(separator: ", ")
400+
: "<" + genericParameters.map { "\($0): BridgedSwiftGenericBridgeable" }.joined(separator: ", ")
401401
+ ">"
402402
printer.write("func \(name.backtickIfNeeded())\(genericClause)\(signature) {")
403403
printer.indent {

Plugins/BridgeJS/Sources/BridgeJSCore/SwiftToSkeleton.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,8 @@ public final class SwiftToSkeleton {
746746
}
747747

748748
fileprivate static func isBridgeableGenericConstraint(_ constraint: String?) -> Bool {
749-
constraint == "_BridgedSwiftGenericBridgeable"
750-
|| constraint == "JavaScriptKit._BridgedSwiftGenericBridgeable"
749+
constraint == "BridgedSwiftGenericBridgeable"
750+
|| constraint == "JavaScriptKit.BridgedSwiftGenericBridgeable"
751751
}
752752

753753
}
@@ -1337,7 +1337,7 @@ private final class ExportSwiftAPICollector: SyntaxAnyVisitor {
13371337
diagnose(
13381338
node: node,
13391339
message:
1340-
"Generic parameter '\(genericParam.name.text)' must be constrained to '_BridgedSwiftGenericBridgeable' to be used with @JS."
1340+
"Generic parameter '\(genericParam.name.text)' must be constrained to 'BridgedSwiftGenericBridgeable' to be used with @JS."
13411341
)
13421342
return nil
13431343
}
@@ -3100,7 +3100,7 @@ private final class ImportSwiftMacrosAPICollector: SyntaxAnyVisitor {
31003100
DiagnosticError(
31013101
node: Syntax(genericParam),
31023102
message:
3103-
"Generic parameter '\(paramName)' must be constrained to '_BridgedSwiftGenericBridgeable' to be used with @JSFunction."
3103+
"Generic parameter '\(paramName)' must be constrained to 'BridgedSwiftGenericBridgeable' to be used with @JSFunction."
31043104
)
31053105
)
31063106
return nil

Plugins/BridgeJS/Tests/BridgeJSToolTests/BridgeJSLinkTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ import Testing
179179
moduleName: "FirstModule",
180180
source: structSource + """
181181
182-
@JS public func identity<T: _BridgedSwiftGenericBridgeable>(_ value: T) -> T { value }
182+
@JS public func identity<T: BridgedSwiftGenericBridgeable>(_ value: T) -> T { value }
183183
"""
184184
)
185185
let second = try makeSkeleton(moduleName: "SecondModule", source: structSource)

Plugins/BridgeJS/Tests/BridgeJSToolTests/GenericExportDiagnosticsTests.swift

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ import Testing
1414
source: """
1515
@JS public func identity<T>(_ value: T) -> T { value }
1616
""",
17-
contains: "Generic parameter 'T' must be constrained to '_BridgedSwiftGenericBridgeable'"
17+
contains: "Generic parameter 'T' must be constrained to 'BridgedSwiftGenericBridgeable'"
1818
)
1919
}
2020

2121
@Test
2222
func genericWhereClauseUnsupported() {
2323
expectDiagnostic(
2424
source: """
25-
@JS public func identity<T: _BridgedSwiftGenericBridgeable>(_ value: T) -> T where T: Sendable { value }
25+
@JS public func identity<T: BridgedSwiftGenericBridgeable>(_ value: T) -> T where T: Sendable { value }
2626
""",
2727
contains: "'where' clauses are not supported"
2828
)
@@ -32,7 +32,7 @@ import Testing
3232
func asyncGenericExportUnsupported() {
3333
expectDiagnostic(
3434
source: """
35-
@JS public func f<T: _BridgedSwiftGenericBridgeable>(_ v: T) async -> T { v }
35+
@JS public func f<T: BridgedSwiftGenericBridgeable>(_ v: T) async -> T { v }
3636
""",
3737
contains: "Generic @JS functions cannot be 'async' yet."
3838
)
@@ -42,17 +42,17 @@ import Testing
4242
func throwsGenericExportUnsupported() {
4343
expectDiagnostic(
4444
source: """
45-
@JS public func f<T: _BridgedSwiftGenericBridgeable>(_ v: T) throws(JSException) -> T { v }
45+
@JS public func f<T: BridgedSwiftGenericBridgeable>(_ v: T) throws(JSException) -> T { v }
4646
""",
4747
contains: "Generic @JS functions cannot be 'throws' yet."
4848
)
4949
}
5050

5151
@Test(arguments: [
52-
("[[T]]", "@JS public func f<T: _BridgedSwiftGenericBridgeable>(_ v: [[T]]) {}"),
53-
("[T?]", "@JS public func f<T: _BridgedSwiftGenericBridgeable>(_ v: [T?]) {}"),
54-
("T??", "@JS public func f<T: _BridgedSwiftGenericBridgeable>(_ v: T??) {}"),
55-
("[Int: T]", "@JS public func f<T: _BridgedSwiftGenericBridgeable>(_ v: [Int: T]) {}"),
52+
("[[T]]", "@JS public func f<T: BridgedSwiftGenericBridgeable>(_ v: [[T]]) {}"),
53+
("[T?]", "@JS public func f<T: BridgedSwiftGenericBridgeable>(_ v: [T?]) {}"),
54+
("T??", "@JS public func f<T: BridgedSwiftGenericBridgeable>(_ v: T??) {}"),
55+
("[Int: T]", "@JS public func f<T: BridgedSwiftGenericBridgeable>(_ v: [Int: T]) {}"),
5656
])
5757
func unsupportedGenericWrapperFormsInParameter(label: String, source: String) {
5858
expectDiagnostic(
@@ -62,10 +62,10 @@ import Testing
6262
}
6363

6464
@Test(arguments: [
65-
("[[T]]", "@JS public func f<T: _BridgedSwiftGenericBridgeable>(_ v: T) -> [[T]] { [[v]] }"),
66-
("[T?]", "@JS public func f<T: _BridgedSwiftGenericBridgeable>(_ v: T) -> [T?] { [v] }"),
67-
("T??", "@JS public func f<T: _BridgedSwiftGenericBridgeable>(_ v: T) -> T?? { v }"),
68-
("[Int: T]", "@JS public func f<T: _BridgedSwiftGenericBridgeable>(_ v: T) -> [Int: T] { [0: v] }"),
65+
("[[T]]", "@JS public func f<T: BridgedSwiftGenericBridgeable>(_ v: T) -> [[T]] { [[v]] }"),
66+
("[T?]", "@JS public func f<T: BridgedSwiftGenericBridgeable>(_ v: T) -> [T?] { [v] }"),
67+
("T??", "@JS public func f<T: BridgedSwiftGenericBridgeable>(_ v: T) -> T?? { v }"),
68+
("[Int: T]", "@JS public func f<T: BridgedSwiftGenericBridgeable>(_ v: T) -> [Int: T] { [0: v] }"),
6969
])
7070
func unsupportedGenericWrapperFormsInReturn(label: String, source: String) {
7171
expectDiagnostic(
@@ -78,7 +78,7 @@ import Testing
7878
func fullyUnusedGenericParameterRejected() {
7979
expectDiagnostic(
8080
source: """
81-
@JS public func combine<T: _BridgedSwiftGenericBridgeable, U: _BridgedSwiftGenericBridgeable>(_ a: T) -> T { a }
81+
@JS public func combine<T: BridgedSwiftGenericBridgeable, U: BridgedSwiftGenericBridgeable>(_ a: T) -> T { a }
8282
""",
8383
contains: "must be used in at least one parameter"
8484
)
@@ -88,7 +88,7 @@ import Testing
8888
func genericParameterMustBeUsedAsParameter() {
8989
expectDiagnostic(
9090
source: """
91-
@JS public func f<T: _BridgedSwiftGenericBridgeable>() -> T { fatalError() }
91+
@JS public func f<T: BridgedSwiftGenericBridgeable>() -> T { fatalError() }
9292
""",
9393
contains: "must be used in at least one parameter"
9494
)
@@ -98,7 +98,7 @@ import Testing
9898
func genericConcreteReturnUnsupported() {
9999
expectDiagnostic(
100100
source: """
101-
@JS public func f<T: _BridgedSwiftGenericBridgeable>(_ v: T) -> String { "" }
101+
@JS public func f<T: BridgedSwiftGenericBridgeable>(_ v: T) -> String { "" }
102102
""",
103103
contains: "must return the generic type"
104104
)
@@ -110,7 +110,7 @@ import Testing
110110
source: """
111111
@JS class Box {
112112
@JS init() {}
113-
@JS func wrap<T: _BridgedSwiftGenericBridgeable>(_ v: T) async -> T { v }
113+
@JS func wrap<T: BridgedSwiftGenericBridgeable>(_ v: T) async -> T { v }
114114
}
115115
""",
116116
contains: "Generic @JS functions cannot be 'async' yet."
@@ -123,7 +123,7 @@ import Testing
123123
source: """
124124
@JS class Box {
125125
@JS init() {}
126-
@JS func wrap<T: _BridgedSwiftGenericBridgeable>(_ v: T) throws(JSException) -> T { v }
126+
@JS func wrap<T: BridgedSwiftGenericBridgeable>(_ v: T) throws(JSException) -> T { v }
127127
}
128128
""",
129129
contains: "Generic @JS functions cannot be 'throws' yet."
@@ -136,7 +136,7 @@ import Testing
136136
source: """
137137
@JS class Box {
138138
@JS init() {}
139-
@JS func wrap<T: _BridgedSwiftGenericBridgeable>(_ v: T) -> T where T: Sendable { v }
139+
@JS func wrap<T: BridgedSwiftGenericBridgeable>(_ v: T) -> T where T: Sendable { v }
140140
}
141141
""",
142142
contains: "'where' clauses are not supported on generic @JS functions."
@@ -153,7 +153,7 @@ import Testing
153153
}
154154
""",
155155
contains:
156-
"Generic parameter 'T' must be constrained to '_BridgedSwiftGenericBridgeable' to be used with @JS."
156+
"Generic parameter 'T' must be constrained to 'BridgedSwiftGenericBridgeable' to be used with @JS."
157157
)
158158
}
159159

@@ -163,7 +163,7 @@ import Testing
163163
source: """
164164
@JS class Box {
165165
@JS init() {}
166-
@JS func count<T: _BridgedSwiftGenericBridgeable>(_ v: T) -> Int { 0 }
166+
@JS func count<T: BridgedSwiftGenericBridgeable>(_ v: T) -> Int { 0 }
167167
}
168168
""",
169169
contains: "must return the generic type"
@@ -176,7 +176,7 @@ import Testing
176176
source: """
177177
@JS enum E {
178178
case a
179-
@JS func f<T: _BridgedSwiftGenericBridgeable>(_ v: T) -> T { v }
179+
@JS func f<T: BridgedSwiftGenericBridgeable>(_ v: T) -> T { v }
180180
}
181181
""",
182182
contains: "Only static functions are supported in enums"

Plugins/BridgeJS/Tests/BridgeJSToolTests/GenericImportDiagnosticsTests.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ import Testing
1414
source: """
1515
@JSFunction func identity<T>(_ value: T) throws(JSException) -> T
1616
""",
17-
contains: "Generic parameter 'T' must be constrained to '_BridgedSwiftGenericBridgeable'"
17+
contains: "Generic parameter 'T' must be constrained to 'BridgedSwiftGenericBridgeable'"
1818
)
1919
}
2020

2121
@Test
2222
func genericWhereClauseUnsupported() {
2323
expectDiagnostic(
2424
source: """
25-
@JSFunction func identity<T: _BridgedSwiftGenericBridgeable>(_ value: T) throws(JSException) -> T where T: Sendable
25+
@JSFunction func identity<T: BridgedSwiftGenericBridgeable>(_ value: T) throws(JSException) -> T where T: Sendable
2626
""",
2727
contains: "'where' clauses are not supported on @JSFunction"
2828
)
@@ -32,7 +32,7 @@ import Testing
3232
func asyncGenericImportUnsupported() {
3333
expectDiagnostic(
3434
source: """
35-
@JSFunction func identityAsync<T: _BridgedSwiftGenericBridgeable>(_ value: T) async throws(JSException) -> T
35+
@JSFunction func identityAsync<T: BridgedSwiftGenericBridgeable>(_ value: T) async throws(JSException) -> T
3636
""",
3737
contains: "Generic @JSFunction declarations cannot be 'async' yet."
3838
)
@@ -43,7 +43,7 @@ import Testing
4343
let skeleton = try makeSkeleton(
4444
"""
4545
@JSClass struct Box {
46-
@JSFunction func member<T: _BridgedSwiftGenericBridgeable>(_ value: T) throws(JSException) -> T
46+
@JSFunction func member<T: BridgedSwiftGenericBridgeable>(_ value: T) throws(JSException) -> T
4747
}
4848
""",
4949
moduleName: "App"
@@ -56,10 +56,10 @@ import Testing
5656
}
5757

5858
@Test(arguments: [
59-
("[[T]]", "@JSFunction func f<T: _BridgedSwiftGenericBridgeable>(_ v: [[T]]) throws(JSException)"),
60-
("[T?]", "@JSFunction func f<T: _BridgedSwiftGenericBridgeable>(_ v: [T?]) throws(JSException)"),
61-
("T??", "@JSFunction func f<T: _BridgedSwiftGenericBridgeable>(_ v: T??) throws(JSException)"),
62-
("[Int: T]", "@JSFunction func f<T: _BridgedSwiftGenericBridgeable>(_ v: [Int: T]) throws(JSException)"),
59+
("[[T]]", "@JSFunction func f<T: BridgedSwiftGenericBridgeable>(_ v: [[T]]) throws(JSException)"),
60+
("[T?]", "@JSFunction func f<T: BridgedSwiftGenericBridgeable>(_ v: [T?]) throws(JSException)"),
61+
("T??", "@JSFunction func f<T: BridgedSwiftGenericBridgeable>(_ v: T??) throws(JSException)"),
62+
("[Int: T]", "@JSFunction func f<T: BridgedSwiftGenericBridgeable>(_ v: [Int: T]) throws(JSException)"),
6363
])
6464
func unsupportedGenericWrapperFormsInParameter(label: String, source: String) {
6565
expectDiagnostic(
@@ -69,10 +69,10 @@ import Testing
6969
}
7070

7171
@Test(arguments: [
72-
("[[T]]", "@JSFunction func f<T: _BridgedSwiftGenericBridgeable>(_ v: T) throws(JSException) -> [[T]]"),
73-
("[T?]", "@JSFunction func f<T: _BridgedSwiftGenericBridgeable>(_ v: T) throws(JSException) -> [T?]"),
74-
("T??", "@JSFunction func f<T: _BridgedSwiftGenericBridgeable>(_ v: T) throws(JSException) -> T??"),
75-
("[Int: T]", "@JSFunction func f<T: _BridgedSwiftGenericBridgeable>(_ v: T) throws(JSException) -> [Int: T]"),
72+
("[[T]]", "@JSFunction func f<T: BridgedSwiftGenericBridgeable>(_ v: T) throws(JSException) -> [[T]]"),
73+
("[T?]", "@JSFunction func f<T: BridgedSwiftGenericBridgeable>(_ v: T) throws(JSException) -> [T?]"),
74+
("T??", "@JSFunction func f<T: BridgedSwiftGenericBridgeable>(_ v: T) throws(JSException) -> T??"),
75+
("[Int: T]", "@JSFunction func f<T: BridgedSwiftGenericBridgeable>(_ v: T) throws(JSException) -> [Int: T]"),
7676
])
7777
func unsupportedGenericWrapperFormsInReturn(label: String, source: String) {
7878
expectDiagnostic(
@@ -86,7 +86,7 @@ import Testing
8686
expectDiagnostic(
8787
source: """
8888
@JSClass struct Box {
89-
@JSFunction func member<T: _BridgedSwiftGenericBridgeable>(_ value: T) async throws(JSException) -> T
89+
@JSFunction func member<T: BridgedSwiftGenericBridgeable>(_ value: T) async throws(JSException) -> T
9090
}
9191
""",
9292
contains: "Generic @JSFunction declarations cannot be 'async' yet."
@@ -102,15 +102,15 @@ import Testing
102102
}
103103
""",
104104
contains:
105-
"Generic parameter 'T' must be constrained to '_BridgedSwiftGenericBridgeable' to be used with @JSFunction."
105+
"Generic parameter 'T' must be constrained to 'BridgedSwiftGenericBridgeable' to be used with @JSFunction."
106106
)
107107
}
108108

109109
@Test
110110
func genericImportedFunctionUnusedTypeParamIsRejected() {
111111
expectDiagnostic(
112112
source: """
113-
@JSFunction func unused<T: _BridgedSwiftGenericBridgeable>() throws(JSException) -> Int
113+
@JSFunction func unused<T: BridgedSwiftGenericBridgeable>() throws(JSException) -> Int
114114
""",
115115
contains:
116116
"The generic parameter 'T' must be used in a parameter or return type of a generic @JSFunction declaration."
@@ -122,7 +122,7 @@ import Testing
122122
expectDiagnostic(
123123
source: """
124124
@JSClass struct Box {
125-
@JSFunction func member<T: _BridgedSwiftGenericBridgeable>() throws(JSException) -> Int
125+
@JSFunction func member<T: BridgedSwiftGenericBridgeable>() throws(JSException) -> Int
126126
}
127127
""",
128128
contains:
@@ -134,7 +134,7 @@ import Testing
134134
func genericImportedReturnOnlyTypeParamIsAllowed() throws {
135135
let skeleton = try makeSkeleton(
136136
"""
137-
@JSFunction func make<T: _BridgedSwiftGenericBridgeable>() throws(JSException) -> T
137+
@JSFunction func make<T: BridgedSwiftGenericBridgeable>() throws(JSException) -> T
138138
""",
139139
moduleName: "App"
140140
)

0 commit comments

Comments
 (0)