Extend family stencil
This commit is contained in:
parent
5b73722a04
commit
dd2c125664
|
|
@ -23,12 +23,20 @@
|
|||
{% map components into compsTypeParams using comp %}{% if not maploop.first %}_ {% endif %}{{ comp|lowercase }}: {{ comp }}.Type{% endmap %}
|
||||
{% set CompsTypeParams %}{{compsTypeParams|join: ", "}}{% endset %}
|
||||
{% map components into compsNamedParams using comp %}{% if not maploop.first %}_ {% endif %}{{ comp|lowercase }}: {{ comp }}{% endmap %}
|
||||
{% set CompsNamedParams %}{{compsNamedParams|join: ", "}}{% endset %}
|
||||
{% set CompsNamedParams %}{{compsNamedParams|join: ", "}}{% endset %}
|
||||
{% map components into compsNamedRParams using comp %}_ {{ comp|lowercase }}: R.{{ comp }}{% endmap %}
|
||||
{% set CompsNamedRParams %}{{compsNamedRParams|join: ", "}}{% endset %}
|
||||
|
||||
// MARK: - Family {{ idx }}
|
||||
|
||||
public typealias Family{{ idx }}<{{ CompParams }}> = Family<Requires{{ idx }}<{{ CompParams }}>> where {{ CompsWhere }}
|
||||
|
||||
public protocol RequiringComponents{{ idx }}: FamilyRequirementsManaging where Components == ({{ CompParams }}) {
|
||||
{% for comp in components %}
|
||||
associatedtype {{ comp }}: Component
|
||||
{% endfor %}
|
||||
}
|
||||
|
||||
public struct Requires{{ idx }}<{{ CompParams }}>: FamilyRequirementsManaging where {{ CompsWhere }} {
|
||||
public let componentTypes: [Component.Type]
|
||||
|
||||
|
|
@ -56,6 +64,14 @@ public struct Requires{{ idx }}<{{ CompParams }}>: FamilyRequirementsManaging wh
|
|||
}
|
||||
}
|
||||
|
||||
extension Requires{{ idx }}: RequiringComponents{{ idx }} { }
|
||||
|
||||
extension FamilyMemberBuilder where R: RequiringComponents{{ idx }} {
|
||||
public static func buildBlock({{ CompsNamedRParams }}) -> (R.Components) {
|
||||
return ({{ CompsLowercased }})
|
||||
}
|
||||
}
|
||||
|
||||
extension Requires{{ idx }}: FamilyEncoding where {{ CompsWhereEncodable }} {
|
||||
public static func encode(components: ({{ CompParams }}), into container: inout KeyedEncodingContainer<DynamicCodingKey>, using strategy: CodingStrategy) throws {
|
||||
{% if compEncodable.count == 1 %}
|
||||
|
|
|
|||
Loading…
Reference in New Issue