Skip to content

Commit 49c7ab1

Browse files
committed
update enums
1 parent de8852f commit 49c7ab1

File tree

4 files changed

+32
-13
lines changed

4 files changed

+32
-13
lines changed

Sources/PolymorphCore/Enum.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ public class Enum: Object, Documentable, Packageable {
2323
public enum RawType: String, Codable {
2424
case int
2525
case string
26+
27+
public static func all() -> [RawType] {
28+
return [
29+
.int,
30+
.string
31+
]
32+
}
2633
}
2734

2835
public struct Value: Documentable, Codable {

Sources/PolymorphCore/External.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ public class External: Object, Documentable, Packageable {
1313
case `class`
1414
case interface
1515
case `enum`
16+
17+
public static func all() -> [ExternalType] {
18+
return [
19+
.class,
20+
.interface,
21+
.enum
22+
]
23+
}
1624
}
1725

1826
// MARK: Codable

Sources/PolymorphCore/Native.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,22 @@ public class Native: Member {
2222
case url = "URL"
2323
case multilingual = "Multilingual"
2424

25+
public static func all() -> [DataType] {
26+
return [
27+
.int,
28+
.bool,
29+
.double,
30+
.float,
31+
.date,
32+
.string,
33+
.data,
34+
.array,
35+
.map,
36+
.url,
37+
.multilingual
38+
]
39+
}
40+
2541
public static func from(string: String) -> DataType? {
2642
return Native.mapping[string.lowercased()]
2743
}

Sources/PolymorphCore/NativeFactory.swift

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,10 @@ import Foundation
99

1010
internal class NativeFactory {
1111

12-
internal static let dataTypes: [Native.DataType] = [
13-
.int,
14-
.bool,
15-
.double,
16-
.float,
17-
.date,
18-
.string,
19-
.data,
20-
.array,
21-
.map
22-
]
23-
2412
internal static func create(project: Project) -> [UUID: Native] {
2513
var idx = 1
2614
var natives = [UUID: Native]()
27-
NativeFactory.dataTypes.forEach {
15+
Native.DataType.all().forEach {
2816
guard let uuid = UUID(uuidString: "00000001-0000-0000-0000-\(String(format: "%012d", idx))") else {
2917
return
3018
}

0 commit comments

Comments
 (0)