Skip to content

Commit 5bc9122

Browse files
committed
BridgeJS: fix code generation for public enums
1 parent 46182e2 commit 5bc9122

5 files changed

Lines changed: 22 additions & 21 deletions

File tree

Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ struct EnumCodegen {
966966
)
967967
printer.nextLine()
968968

969-
printer.write("private init?(bridgeJSRawValue: Int32) {")
969+
printer.write("@_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) {")
970970
printer.indent {
971971
printer.write("switch bridgeJSRawValue {")
972972
for (index, enumCase) in enumDef.cases.enumerated() {
@@ -984,7 +984,7 @@ struct EnumCodegen {
984984
printer.write("}")
985985
printer.nextLine()
986986

987-
printer.write("private var bridgeJSRawValue: Int32 {")
987+
printer.write("@_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 {")
988988
printer.indent {
989989
printer.write("switch self {")
990990
for (index, enumCase) in enumDef.cases.enumerated() {

Tests/BridgeJSGlobalTests/Generated/BridgeJS.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extension GlobalNetworking.API.CallMethod: _BridgedSwiftCaseEnum {
2121
return bridgeJSLowerParameter()
2222
}
2323

24-
private init?(bridgeJSRawValue: Int32) {
24+
@_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) {
2525
switch bridgeJSRawValue {
2626
case 0:
2727
self = .get
@@ -36,7 +36,7 @@ extension GlobalNetworking.API.CallMethod: _BridgedSwiftCaseEnum {
3636
}
3737
}
3838

39-
private var bridgeJSRawValue: Int32 {
39+
@_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 {
4040
switch self {
4141
case .get:
4242
return 0
@@ -70,7 +70,7 @@ extension Internal.SupportedServerMethod: _BridgedSwiftCaseEnum {
7070
return bridgeJSLowerParameter()
7171
}
7272

73-
private init?(bridgeJSRawValue: Int32) {
73+
@_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) {
7474
switch bridgeJSRawValue {
7575
case 0:
7676
self = .get
@@ -81,7 +81,7 @@ extension Internal.SupportedServerMethod: _BridgedSwiftCaseEnum {
8181
}
8282
}
8383

84-
private var bridgeJSRawValue: Int32 {
84+
@_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 {
8585
switch self {
8686
case .get:
8787
return 0

Tests/BridgeJSRuntimeTests/ExportAPITests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ extension Greeter {
207207

208208
// MARK: - Enum Tests
209209

210-
@JS enum Direction {
210+
@JS public enum Direction {
211211
case north
212212
case south
213213
case east

Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3868,7 +3868,7 @@ extension Direction: _BridgedSwiftCaseEnum {
38683868
return bridgeJSLowerParameter()
38693869
}
38703870

3871-
private init?(bridgeJSRawValue: Int32) {
3871+
@_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) {
38723872
switch bridgeJSRawValue {
38733873
case 0:
38743874
self = .north
@@ -3883,7 +3883,7 @@ extension Direction: _BridgedSwiftCaseEnum {
38833883
}
38843884
}
38853885

3886-
private var bridgeJSRawValue: Int32 {
3886+
@_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 {
38873887
switch self {
38883888
case .north:
38893889
return 0
@@ -3911,7 +3911,7 @@ extension Status: _BridgedSwiftCaseEnum {
39113911
return bridgeJSLowerParameter()
39123912
}
39133913

3914-
private init?(bridgeJSRawValue: Int32) {
3914+
@_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) {
39153915
switch bridgeJSRawValue {
39163916
case 0:
39173917
self = .loading
@@ -3924,7 +3924,7 @@ extension Status: _BridgedSwiftCaseEnum {
39243924
}
39253925
}
39263926

3927-
private var bridgeJSRawValue: Int32 {
3927+
@_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 {
39283928
switch self {
39293929
case .loading:
39303930
return 0
@@ -3968,7 +3968,7 @@ extension TSDirection: _BridgedSwiftCaseEnum {
39683968
return bridgeJSLowerParameter()
39693969
}
39703970

3971-
private init?(bridgeJSRawValue: Int32) {
3971+
@_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) {
39723972
switch bridgeJSRawValue {
39733973
case 0:
39743974
self = .north
@@ -3983,7 +3983,7 @@ extension TSDirection: _BridgedSwiftCaseEnum {
39833983
}
39843984
}
39853985

3986-
private var bridgeJSRawValue: Int32 {
3986+
@_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 {
39873987
switch self {
39883988
case .north:
39893989
return 0
@@ -4036,7 +4036,7 @@ extension Networking.API.Method: _BridgedSwiftCaseEnum {
40364036
return bridgeJSLowerParameter()
40374037
}
40384038

4039-
private init?(bridgeJSRawValue: Int32) {
4039+
@_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) {
40404040
switch bridgeJSRawValue {
40414041
case 0:
40424042
self = .get
@@ -4051,7 +4051,7 @@ extension Networking.API.Method: _BridgedSwiftCaseEnum {
40514051
}
40524052
}
40534053

4054-
private var bridgeJSRawValue: Int32 {
4054+
@_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 {
40554055
switch self {
40564056
case .get:
40574057
return 0
@@ -4085,7 +4085,7 @@ extension Internal.SupportedMethod: _BridgedSwiftCaseEnum {
40854085
return bridgeJSLowerParameter()
40864086
}
40874087

4088-
private init?(bridgeJSRawValue: Int32) {
4088+
@_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) {
40894089
switch bridgeJSRawValue {
40904090
case 0:
40914091
self = .get
@@ -4096,7 +4096,7 @@ extension Internal.SupportedMethod: _BridgedSwiftCaseEnum {
40964096
}
40974097
}
40984098

4099-
private var bridgeJSRawValue: Int32 {
4099+
@_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 {
41004100
switch self {
41014101
case .get:
41024102
return 0
@@ -4369,7 +4369,7 @@ extension StaticCalculator: _BridgedSwiftCaseEnum {
43694369
return bridgeJSLowerParameter()
43704370
}
43714371

4372-
private init?(bridgeJSRawValue: Int32) {
4372+
@_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) {
43734373
switch bridgeJSRawValue {
43744374
case 0:
43754375
self = .scientific
@@ -4380,7 +4380,7 @@ extension StaticCalculator: _BridgedSwiftCaseEnum {
43804380
}
43814381
}
43824382

4383-
private var bridgeJSRawValue: Int32 {
4383+
@_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 {
43844384
switch self {
43854385
case .scientific:
43864386
return 0
@@ -4470,7 +4470,7 @@ extension StaticPropertyEnum: _BridgedSwiftCaseEnum {
44704470
return bridgeJSLowerParameter()
44714471
}
44724472

4473-
private init?(bridgeJSRawValue: Int32) {
4473+
@_spi(BridgeJS) @usableFromInline init?(bridgeJSRawValue: Int32) {
44744474
switch bridgeJSRawValue {
44754475
case 0:
44764476
self = .option1
@@ -4481,7 +4481,7 @@ extension StaticPropertyEnum: _BridgedSwiftCaseEnum {
44814481
}
44824482
}
44834483

4484-
private var bridgeJSRawValue: Int32 {
4484+
@_spi(BridgeJS) @usableFromInline var bridgeJSRawValue: Int32 {
44854485
switch self {
44864486
case .option1:
44874487
return 0

Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7235,6 +7235,7 @@
72357235
}
72367236
],
72377237
"emitStyle" : "const",
7238+
"explicitAccessControl" : "public",
72387239
"name" : "Direction",
72397240
"staticMethods" : [
72407241

0 commit comments

Comments
 (0)