This commit is contained in:
Christian Treffs 2020-08-07 10:50:38 +02:00
parent dd2c125664
commit de270761f8
No known key found for this signature in database
GPG Key ID: 49A4B4B460BE3ED4
1 changed files with 124 additions and 0 deletions

View File

@ -11,6 +11,10 @@
public typealias Family1<Comp1> = Family<Requires1<Comp1>> where Comp1: Component
public protocol RequiringComponents1: FamilyRequirementsManaging where Components == (Comp1) {
associatedtype Comp1: Component
}
public struct Requires1<Comp1>: FamilyRequirementsManaging where Comp1: Component {
public let componentTypes: [Component.Type]
@ -34,6 +38,14 @@ public struct Requires1<Comp1>: FamilyRequirementsManaging where Comp1: Componen
}
}
extension Requires1: RequiringComponents1 { }
extension FamilyMemberBuilder where R: RequiringComponents1 {
public static func buildBlock(_ comp1: R.Comp1) -> (R.Components) {
(comp1)
}
}
extension Requires1: FamilyEncoding where Comp1: Encodable {
public static func encode(components: (Comp1), into container: inout KeyedEncodingContainer<DynamicCodingKey>, using strategy: CodingStrategy) throws {
try container.encode(components, forKey: strategy.codingKey(for: Comp1.self))
@ -91,6 +103,11 @@ extension Nexus {
public typealias Family2<Comp1, Comp2> = Family<Requires2<Comp1, Comp2>> where Comp1: Component, Comp2: Component
public protocol RequiringComponents2: FamilyRequirementsManaging where Components == (Comp1, Comp2) {
associatedtype Comp1: Component
associatedtype Comp2: Component
}
public struct Requires2<Comp1, Comp2>: FamilyRequirementsManaging where Comp1: Component, Comp2: Component {
public let componentTypes: [Component.Type]
@ -116,6 +133,14 @@ public struct Requires2<Comp1, Comp2>: FamilyRequirementsManaging where Comp1: C
}
}
extension Requires2: RequiringComponents2 { }
extension FamilyMemberBuilder where R: RequiringComponents2 {
public static func buildBlock(_ comp1: R.Comp1, _ comp2: R.Comp2) -> (R.Components) {
(comp1, comp2)
}
}
extension Requires2: FamilyEncoding where Comp1: Encodable, Comp2: Encodable {
public static func encode(components: (Comp1, Comp2), into container: inout KeyedEncodingContainer<DynamicCodingKey>, using strategy: CodingStrategy) throws {
try container.encode(components.0, forKey: strategy.codingKey(for: Comp1.self))
@ -176,6 +201,12 @@ extension Nexus {
public typealias Family3<Comp1, Comp2, Comp3> = Family<Requires3<Comp1, Comp2, Comp3>> where Comp1: Component, Comp2: Component, Comp3: Component
public protocol RequiringComponents3: FamilyRequirementsManaging where Components == (Comp1, Comp2, Comp3) {
associatedtype Comp1: Component
associatedtype Comp2: Component
associatedtype Comp3: Component
}
public struct Requires3<Comp1, Comp2, Comp3>: FamilyRequirementsManaging where Comp1: Component, Comp2: Component, Comp3: Component {
public let componentTypes: [Component.Type]
@ -203,6 +234,14 @@ public struct Requires3<Comp1, Comp2, Comp3>: FamilyRequirementsManaging where C
}
}
extension Requires3: RequiringComponents3 { }
extension FamilyMemberBuilder where R: RequiringComponents3 {
public static func buildBlock(_ comp1: R.Comp1, _ comp2: R.Comp2, _ comp3: R.Comp3) -> (R.Components) {
(comp1, comp2, comp3)
}
}
extension Requires3: FamilyEncoding where Comp1: Encodable, Comp2: Encodable, Comp3: Encodable {
public static func encode(components: (Comp1, Comp2, Comp3), into container: inout KeyedEncodingContainer<DynamicCodingKey>, using strategy: CodingStrategy) throws {
try container.encode(components.0, forKey: strategy.codingKey(for: Comp1.self))
@ -266,6 +305,13 @@ extension Nexus {
public typealias Family4<Comp1, Comp2, Comp3, Comp4> = Family<Requires4<Comp1, Comp2, Comp3, Comp4>> where Comp1: Component, Comp2: Component, Comp3: Component, Comp4: Component
public protocol RequiringComponents4: FamilyRequirementsManaging where Components == (Comp1, Comp2, Comp3, Comp4) {
associatedtype Comp1: Component
associatedtype Comp2: Component
associatedtype Comp3: Component
associatedtype Comp4: Component
}
public struct Requires4<Comp1, Comp2, Comp3, Comp4>: FamilyRequirementsManaging where Comp1: Component, Comp2: Component, Comp3: Component, Comp4: Component {
public let componentTypes: [Component.Type]
@ -295,6 +341,14 @@ public struct Requires4<Comp1, Comp2, Comp3, Comp4>: FamilyRequirementsManaging
}
}
extension Requires4: RequiringComponents4 { }
extension FamilyMemberBuilder where R: RequiringComponents4 {
public static func buildBlock(_ comp1: R.Comp1, _ comp2: R.Comp2, _ comp3: R.Comp3, _ comp4: R.Comp4) -> (R.Components) {
(comp1, comp2, comp3, comp4)
}
}
extension Requires4: FamilyEncoding where Comp1: Encodable, Comp2: Encodable, Comp3: Encodable, Comp4: Encodable {
public static func encode(components: (Comp1, Comp2, Comp3, Comp4), into container: inout KeyedEncodingContainer<DynamicCodingKey>, using strategy: CodingStrategy) throws {
try container.encode(components.0, forKey: strategy.codingKey(for: Comp1.self))
@ -361,6 +415,14 @@ extension Nexus {
public typealias Family5<Comp1, Comp2, Comp3, Comp4, Comp5> = Family<Requires5<Comp1, Comp2, Comp3, Comp4, Comp5>> where Comp1: Component, Comp2: Component, Comp3: Component, Comp4: Component, Comp5: Component
public protocol RequiringComponents5: FamilyRequirementsManaging where Components == (Comp1, Comp2, Comp3, Comp4, Comp5) {
associatedtype Comp1: Component
associatedtype Comp2: Component
associatedtype Comp3: Component
associatedtype Comp4: Component
associatedtype Comp5: Component
}
public struct Requires5<Comp1, Comp2, Comp3, Comp4, Comp5>: FamilyRequirementsManaging where Comp1: Component, Comp2: Component, Comp3: Component, Comp4: Component, Comp5: Component {
public let componentTypes: [Component.Type]
@ -392,6 +454,14 @@ public struct Requires5<Comp1, Comp2, Comp3, Comp4, Comp5>: FamilyRequirementsMa
}
}
extension Requires5: RequiringComponents5 { }
extension FamilyMemberBuilder where R: RequiringComponents5 {
public static func buildBlock(_ comp1: R.Comp1, _ comp2: R.Comp2, _ comp3: R.Comp3, _ comp4: R.Comp4, _ comp5: R.Comp5) -> (R.Components) {
(comp1, comp2, comp3, comp4, comp5)
}
}
extension Requires5: FamilyEncoding where Comp1: Encodable, Comp2: Encodable, Comp3: Encodable, Comp4: Encodable, Comp5: Encodable {
public static func encode(components: (Comp1, Comp2, Comp3, Comp4, Comp5), into container: inout KeyedEncodingContainer<DynamicCodingKey>, using strategy: CodingStrategy) throws {
try container.encode(components.0, forKey: strategy.codingKey(for: Comp1.self))
@ -461,6 +531,15 @@ extension Nexus {
public typealias Family6<Comp1, Comp2, Comp3, Comp4, Comp5, Comp6> = Family<Requires6<Comp1, Comp2, Comp3, Comp4, Comp5, Comp6>> where Comp1: Component, Comp2: Component, Comp3: Component, Comp4: Component, Comp5: Component, Comp6: Component
public protocol RequiringComponents6: FamilyRequirementsManaging where Components == (Comp1, Comp2, Comp3, Comp4, Comp5, Comp6) {
associatedtype Comp1: Component
associatedtype Comp2: Component
associatedtype Comp3: Component
associatedtype Comp4: Component
associatedtype Comp5: Component
associatedtype Comp6: Component
}
public struct Requires6<Comp1, Comp2, Comp3, Comp4, Comp5, Comp6>: FamilyRequirementsManaging where Comp1: Component, Comp2: Component, Comp3: Component, Comp4: Component, Comp5: Component, Comp6: Component {
public let componentTypes: [Component.Type]
@ -494,6 +573,14 @@ public struct Requires6<Comp1, Comp2, Comp3, Comp4, Comp5, Comp6>: FamilyRequire
}
}
extension Requires6: RequiringComponents6 { }
extension FamilyMemberBuilder where R: RequiringComponents6 {
public static func buildBlock(_ comp1: R.Comp1, _ comp2: R.Comp2, _ comp3: R.Comp3, _ comp4: R.Comp4, _ comp5: R.Comp5, _ comp6: R.Comp6) -> (R.Components) {
(comp1, comp2, comp3, comp4, comp5, comp6)
}
}
extension Requires6: FamilyEncoding where Comp1: Encodable, Comp2: Encodable, Comp3: Encodable, Comp4: Encodable, Comp5: Encodable, Comp6: Encodable {
public static func encode(components: (Comp1, Comp2, Comp3, Comp4, Comp5, Comp6), into container: inout KeyedEncodingContainer<DynamicCodingKey>, using strategy: CodingStrategy) throws {
try container.encode(components.0, forKey: strategy.codingKey(for: Comp1.self))
@ -566,6 +653,16 @@ extension Nexus {
public typealias Family7<Comp1, Comp2, Comp3, Comp4, Comp5, Comp6, Comp7> = Family<Requires7<Comp1, Comp2, Comp3, Comp4, Comp5, Comp6, Comp7>> where Comp1: Component, Comp2: Component, Comp3: Component, Comp4: Component, Comp5: Component, Comp6: Component, Comp7: Component
public protocol RequiringComponents7: FamilyRequirementsManaging where Components == (Comp1, Comp2, Comp3, Comp4, Comp5, Comp6, Comp7) {
associatedtype Comp1: Component
associatedtype Comp2: Component
associatedtype Comp3: Component
associatedtype Comp4: Component
associatedtype Comp5: Component
associatedtype Comp6: Component
associatedtype Comp7: Component
}
public struct Requires7<Comp1, Comp2, Comp3, Comp4, Comp5, Comp6, Comp7>: FamilyRequirementsManaging where Comp1: Component, Comp2: Component, Comp3: Component, Comp4: Component, Comp5: Component, Comp6: Component, Comp7: Component {
public let componentTypes: [Component.Type]
@ -601,6 +698,14 @@ public struct Requires7<Comp1, Comp2, Comp3, Comp4, Comp5, Comp6, Comp7>: Family
}
}
extension Requires7: RequiringComponents7 { }
extension FamilyMemberBuilder where R: RequiringComponents7 {
public static func buildBlock(_ comp1: R.Comp1, _ comp2: R.Comp2, _ comp3: R.Comp3, _ comp4: R.Comp4, _ comp5: R.Comp5, _ comp6: R.Comp6, _ comp7: R.Comp7) -> (R.Components) {
(comp1, comp2, comp3, comp4, comp5, comp6, comp7)
}
}
extension Requires7: FamilyEncoding where Comp1: Encodable, Comp2: Encodable, Comp3: Encodable, Comp4: Encodable, Comp5: Encodable, Comp6: Encodable, Comp7: Encodable {
public static func encode(components: (Comp1, Comp2, Comp3, Comp4, Comp5, Comp6, Comp7), into container: inout KeyedEncodingContainer<DynamicCodingKey>, using strategy: CodingStrategy) throws {
try container.encode(components.0, forKey: strategy.codingKey(for: Comp1.self))
@ -676,6 +781,17 @@ extension Nexus {
public typealias Family8<Comp1, Comp2, Comp3, Comp4, Comp5, Comp6, Comp7, Comp8> = Family<Requires8<Comp1, Comp2, Comp3, Comp4, Comp5, Comp6, Comp7, Comp8>> where Comp1: Component, Comp2: Component, Comp3: Component, Comp4: Component, Comp5: Component, Comp6: Component, Comp7: Component, Comp8: Component
public protocol RequiringComponents8: FamilyRequirementsManaging where Components == (Comp1, Comp2, Comp3, Comp4, Comp5, Comp6, Comp7, Comp8) {
associatedtype Comp1: Component
associatedtype Comp2: Component
associatedtype Comp3: Component
associatedtype Comp4: Component
associatedtype Comp5: Component
associatedtype Comp6: Component
associatedtype Comp7: Component
associatedtype Comp8: Component
}
public struct Requires8<Comp1, Comp2, Comp3, Comp4, Comp5, Comp6, Comp7, Comp8>: FamilyRequirementsManaging where Comp1: Component, Comp2: Component, Comp3: Component, Comp4: Component, Comp5: Component, Comp6: Component, Comp7: Component, Comp8: Component {
public let componentTypes: [Component.Type]
@ -713,6 +829,14 @@ public struct Requires8<Comp1, Comp2, Comp3, Comp4, Comp5, Comp6, Comp7, Comp8>:
}
}
extension Requires8: RequiringComponents8 { }
extension FamilyMemberBuilder where R: RequiringComponents8 {
public static func buildBlock(_ comp1: R.Comp1, _ comp2: R.Comp2, _ comp3: R.Comp3, _ comp4: R.Comp4, _ comp5: R.Comp5, _ comp6: R.Comp6, _ comp7: R.Comp7, _ comp8: R.Comp8) -> (R.Components) {
(comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8)
}
}
extension Requires8: FamilyEncoding where Comp1: Encodable, Comp2: Encodable, Comp3: Encodable, Comp4: Encodable, Comp5: Encodable, Comp6: Encodable, Comp7: Encodable, Comp8: Encodable {
public static func encode(components: (Comp1, Comp2, Comp3, Comp4, Comp5, Comp6, Comp7, Comp8), into container: inout KeyedEncodingContainer<DynamicCodingKey>, using strategy: CodingStrategy) throws {
try container.encode(components.0, forKey: strategy.codingKey(for: Comp1.self))