Михаил Капелько 11 months ago
parent
commit
56c897bb9e
3 changed files with 34 additions and 7 deletions
  1. +26
    -0
      Utilities/platform/2/generation/pipeBusSource.py
  2. +1
    -6
      Utilities/platform/2/generation/pipeSource.py
  3. +7
    -1
      Utilities/platform/2/generation/sectionGeneratedPipes.py

+ 26
- 0
Utilities/platform/2/generation/pipeBusSource.py View File

@@ -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
Utilities/platform/2/generation/pipeSource.py View File

@@ -1,6 +1,6 @@
from generation.isNotKeyword import *

def pipeSource(name, entity, structure):
def pipeSource(name, entity):
props = entity.pipes[name]
if "vm" in props:
return "core.vm." + name
@@ -14,11 +14,6 @@ def pipeSource(name, entity, structure):
# Прямое обращение к VM.
if src.startswith("vm."):
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:
return default + "." + name


+ 7
- 1
Utilities/platform/2/generation/sectionGeneratedPipes.py View File

@@ -1,8 +1,11 @@
from generation.shortenName import *
from generation.pipeBusSource import *
from generation.pipeFormat import *
from generation.pipeSource import *

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")
fmtRecent = c.readFile(f"{c.dir}/templates/section-generated-pipe-recent")
fmtSet = c.readFile(f"{c.dir}/templates/section-generated-pipe-set")
@@ -26,7 +29,10 @@ def sectionGeneratedPipes(entity, sub, c):
shortSrc = shortenName(key)

# 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)
for fmt in fmtPipe:


Loading…
Cancel
Save