Skip to content

Commit 0172643

Browse files
Switch ImportedTypeSkeleton back to synthesized Codable
1 parent 55626b2 commit 0172643

File tree

6 files changed

+25
-42
lines changed

6 files changed

+25
-42
lines changed

Plugins/BridgeJS/Sources/BridgeJSSkeleton/BridgeJSSkeleton.swift

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ public struct ImportedTypeSkeleton: Codable {
758758
public let constructor: ImportedConstructorSkeleton?
759759
public let methods: [ImportedFunctionSkeleton]
760760
/// Static methods available on the JavaScript constructor.
761-
public let staticMethods: [ImportedFunctionSkeleton]
761+
public var staticMethods: [ImportedFunctionSkeleton] = []
762762
public let getters: [ImportedGetterSkeleton]
763763
public let setters: [ImportedSetterSkeleton]
764764
public let documentation: String?
@@ -784,47 +784,6 @@ public struct ImportedTypeSkeleton: Codable {
784784
self.setters = setters
785785
self.documentation = documentation
786786
}
787-
788-
private enum CodingKeys: String, CodingKey {
789-
case name
790-
case jsName
791-
case from
792-
case constructor
793-
case methods
794-
case staticMethods
795-
case getters
796-
case setters
797-
case documentation
798-
}
799-
800-
public init(from decoder: any Decoder) throws {
801-
let container = try decoder.container(keyedBy: CodingKeys.self)
802-
self.name = try container.decode(String.self, forKey: .name)
803-
self.jsName = try container.decodeIfPresent(String.self, forKey: .jsName)
804-
self.from = try container.decodeIfPresent(JSImportFrom.self, forKey: .from)
805-
self.constructor = try container.decodeIfPresent(ImportedConstructorSkeleton.self, forKey: .constructor)
806-
self.methods = try container.decode([ImportedFunctionSkeleton].self, forKey: .methods)
807-
self.staticMethods =
808-
try container.decodeIfPresent([ImportedFunctionSkeleton].self, forKey: .staticMethods) ?? []
809-
self.getters = try container.decode([ImportedGetterSkeleton].self, forKey: .getters)
810-
self.setters = try container.decode([ImportedSetterSkeleton].self, forKey: .setters)
811-
self.documentation = try container.decodeIfPresent(String.self, forKey: .documentation)
812-
}
813-
814-
public func encode(to encoder: any Encoder) throws {
815-
var container = encoder.container(keyedBy: CodingKeys.self)
816-
try container.encode(name, forKey: .name)
817-
try container.encodeIfPresent(jsName, forKey: .jsName)
818-
try container.encodeIfPresent(from, forKey: .from)
819-
try container.encodeIfPresent(constructor, forKey: .constructor)
820-
try container.encode(methods, forKey: .methods)
821-
if !staticMethods.isEmpty {
822-
try container.encode(staticMethods, forKey: .staticMethods)
823-
}
824-
try container.encode(getters, forKey: .getters)
825-
try container.encode(setters, forKey: .setters)
826-
try container.encodeIfPresent(documentation, forKey: .documentation)
827-
}
828787
}
829788

830789
public struct ImportedFileSkeleton: Codable {

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/GlobalGetter.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
"name" : "JSConsole",
6262
"setters" : [
6363

64+
],
65+
"staticMethods" : [
66+
6467
]
6568
}
6669
]

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/GlobalThisImports.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@
8181
"name" : "JSConsole",
8282
"setters" : [
8383

84+
],
85+
"staticMethods" : [
86+
8487
]
8588
},
8689
{
@@ -116,6 +119,9 @@
116119
"name" : "WebSocket",
117120
"setters" : [
118121

122+
],
123+
"staticMethods" : [
124+
119125
]
120126
}
121127
]

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@
186186
"name" : "Foo",
187187
"setters" : [
188188

189+
],
190+
"staticMethods" : [
191+
189192
]
190193
}
191194
]

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/InvalidPropertyNames.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@
219219
}
220220
}
221221
}
222+
],
223+
"staticMethods" : [
224+
222225
]
223226
},
224227
{
@@ -248,6 +251,9 @@
248251
"name" : "_Weird",
249252
"setters" : [
250253

254+
],
255+
"staticMethods" : [
256+
251257
]
252258
}
253259
]

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSCodegenTests/JSClass.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@
107107
}
108108
}
109109
}
110+
],
111+
"staticMethods" : [
112+
110113
]
111114
},
112115
{
@@ -162,6 +165,9 @@
162165
"name" : "Animatable",
163166
"setters" : [
164167

168+
],
169+
"staticMethods" : [
170+
165171
]
166172
}
167173
]

0 commit comments

Comments
 (0)