@@ -0,0 +1,26 @@ | |||||
from generation.isNotKeyword import * | |||||
def pipeSource(name, entity, structure, fmtBusPipe, fmtBusPipeToggle): | |||||
props = entity.pipes[name] | |||||
if "vm" in props: | |||||
return "core.vm." + name | |||||
elif "$vm" in props: | |||||
return "core.vm.$" + name | |||||
else: | |||||
# Если это что-то неизвестное заранее, то ищем строку, | |||||
# отличную от известных ключевых слов для инструкции pipe. | |||||
default = "world" | |||||
src = next(filter(isNotKeyword, props), default) | |||||
# Прямое обращение к VM. | |||||
if src.startswith("vm."): | |||||
src = "core." + src | |||||
# Обращение к константе шины. | |||||
elif src.startswith("K."): | |||||
src = pipeSourceBus( | |||||
busKey = src | |||||
busValueType = structure.model.fields[name][0] | |||||
src = "Bus.events.compactMap { Bus.convertKeyValue(" + busKey + ", $0) }.map { (k: String, v: " + busValueType + ") in v }" | |||||
# Значение по умолчанию. | |||||
elif src == default: | |||||
return default + "." + name | |||||
return src |
@@ -1,6 +1,6 @@ | |||||
from generation.isNotKeyword import * | from generation.isNotKeyword import * | ||||
def pipeSource(name, entity, structure): | |||||
def pipeSource(name, entity): | |||||
props = entity.pipes[name] | props = entity.pipes[name] | ||||
if "vm" in props: | if "vm" in props: | ||||
return "core.vm." + name | return "core.vm." + name | ||||
@@ -14,11 +14,6 @@ def pipeSource(name, entity, structure): | |||||
# Прямое обращение к VM. | # Прямое обращение к VM. | ||||
if src.startswith("vm."): | if src.startswith("vm."): | ||||
src = "core." + src | src = "core." + src | ||||
# Обращение к константе шины. | |||||
elif src.startswith("K."): | |||||
busKey = src | |||||
busValueType = structure.model.fields[name][0] | |||||
src = "Bus.events.compactMap { Bus.convertKeyValue(" + busKey + ", $0) }.map { (k: String, v: " + busValueType + ") in v }" | |||||
# Значение по умолчанию. | # Значение по умолчанию. | ||||
elif src == default: | elif src == default: | ||||
return default + "." + name | return default + "." + name | ||||
@@ -1,8 +1,11 @@ | |||||
from generation.shortenName import * | from generation.shortenName import * | ||||
from generation.pipeBusSource import * | |||||
from generation.pipeFormat import * | from generation.pipeFormat import * | ||||
from generation.pipeSource import * | from generation.pipeSource import * | ||||
def sectionGeneratedPipes(entity, sub, c): | def sectionGeneratedPipes(entity, sub, c): | ||||
fmtBusPipe = c.readFile(f"{c.dir}/templates/section-generated-bus-pipe") | |||||
fmtBusPipeToggle = c.readFile(f"{c.dir}/templates/section-generated-bus-pipe-toggle") | |||||
fmtExRecent = c.readFile(f"{c.dir}/templates/section-generated-pipe-ex-recent") | fmtExRecent = c.readFile(f"{c.dir}/templates/section-generated-pipe-ex-recent") | ||||
fmtRecent = c.readFile(f"{c.dir}/templates/section-generated-pipe-recent") | fmtRecent = c.readFile(f"{c.dir}/templates/section-generated-pipe-recent") | ||||
fmtSet = c.readFile(f"{c.dir}/templates/section-generated-pipe-set") | fmtSet = c.readFile(f"{c.dir}/templates/section-generated-pipe-set") | ||||
@@ -26,7 +29,10 @@ def sectionGeneratedPipes(entity, sub, c): | |||||
shortSrc = shortenName(key) | shortSrc = shortenName(key) | ||||
# SRC. | # SRC. | ||||
src = pipeSource(key, entity, c.structure) | |||||
src = pipeSource(key, entity) | |||||
# Bus. | |||||
if src.startswith("K."): | |||||
src = pipeBusSource(key, c.structure, fmtBusPipe, fmtBusPipeToggle) | |||||
fmtPipe = pipeFormat(fmtExRecent, fmtRecent, fmtSet, fmtToggle, fmtToggleNil, key, entity) | fmtPipe = pipeFormat(fmtExRecent, fmtRecent, fmtSet, fmtToggle, fmtToggleNil, key, entity) | ||||
for fmt in fmtPipe: | for fmt in fmtPipe: | ||||