Skip to content

Commit f48a3d7

Browse files
committed
add raw type to enums
1 parent 384810c commit f48a3d7

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Sources/PolymorphCore/Enum.swift

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,22 @@ public class Enum: Object, Documentable, Packageable {
1717
case package
1818
case values
1919
case documentation
20+
case rawType
21+
}
22+
23+
public enum RawType: String, Codable {
24+
case int
25+
case string
2026
}
2127

2228
public struct Value: Documentable, Codable {
2329
public var name: String
24-
public var numeric: Int
30+
public var raw: String
2531
public var documentation: String?
2632

27-
public init(name: String, numeric: Int) {
33+
public init(name: String, raw: String) {
2834
self.name = name
29-
self.numeric = numeric
35+
self.raw = raw
3036
}
3137
}
3238

@@ -36,6 +42,8 @@ public class Enum: Object, Documentable, Packageable {
3642

3743
public var name: String
3844

45+
public var rawType: RawType
46+
3947
public var package: Package
4048

4149
public var documentation: String?
@@ -55,9 +63,10 @@ public class Enum: Object, Documentable, Packageable {
5563

5664
// MARK: Initializers
5765

58-
public init(name: String, package: Package, values: [Value] = []) {
66+
public init(name: String, package: Package, rawType: RawType = .int, values: [Value] = []) {
5967
self.id = UUID()
6068
self.name = name
69+
self.rawType = rawType
6170
self.package = package
6271
self.values = values
6372
}

0 commit comments

Comments
 (0)