From 4dbbcfdc22de56f41c8e76bc10434794c37708d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Thu, 28 Dec 2023 18:30:31 +0300 Subject: [PATCH] d --- .../MeetupIdX/src/MeetupId.Generated.swift | 2 +- .../platform/2/generation/pipeBusSource.py | 34 +++++-------------- .../2/generation/sectionGeneratedPipes.py | 6 ++-- .../templates/section-generated-pipe-src-bus | 6 ++++ .../section-generated-pipe-src-bus-toggle | 6 ++++ 5 files changed, 25 insertions(+), 29 deletions(-) create mode 100644 Utilities/platform/2/templates/section-generated-pipe-src-bus create mode 100644 Utilities/platform/2/templates/section-generated-pipe-src-bus-toggle diff --git a/Modules/MeetupIdX/src/MeetupId.Generated.swift b/Modules/MeetupIdX/src/MeetupId.Generated.swift index 1b80785..9fc57e8 100644 --- a/Modules/MeetupIdX/src/MeetupId.Generated.swift +++ b/Modules/MeetupIdX/src/MeetupId.Generated.swift @@ -93,7 +93,7 @@ extension MeetupId { ctrl.pipe( dbg: "join", sub: nil, - Bus.events.compactMap { Bus.convertKeyValue(K.join, $0) }.map { (k: String, v: Void) in v }.eraseToAnyPublisher(), + Bus.events.compactMap { Bus.convertKeyValue(K.join, $0) }.map { (k: String, v: Void) in v }.map { _ in }.eraseToAnyPublisher(), { $0.join = true }, { $0.join = false } ) diff --git a/Utilities/platform/2/generation/pipeBusSource.py b/Utilities/platform/2/generation/pipeBusSource.py index fb6dab8..4c13524 100644 --- a/Utilities/platform/2/generation/pipeBusSource.py +++ b/Utilities/platform/2/generation/pipeBusSource.py @@ -1,26 +1,10 @@ -from generation.isNotKeyword import * +def pipeBusSource(name, entity, busKey, structure, fmtBusPipe, fmtBusPipeToggle): + if "toggle" in entity.pipes[name]: + return fmtBusPipeToggle \ + .replace("%BUS_KEY%", busKey) \ + .replace("%BUS_VALUE_TYPE%", "Void") -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 + valueType = structure.model.fields[name][0] + return fmtBusPipe \ + .replace("%BUS_KEY%", busKey) \ + .replace("%BUS_VALUE_TYPE%", valueType) diff --git a/Utilities/platform/2/generation/sectionGeneratedPipes.py b/Utilities/platform/2/generation/sectionGeneratedPipes.py index 7b82b4a..3541ac8 100644 --- a/Utilities/platform/2/generation/sectionGeneratedPipes.py +++ b/Utilities/platform/2/generation/sectionGeneratedPipes.py @@ -4,8 +4,8 @@ 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") + fmtBusPipe = c.readFile(f"{c.dir}/templates/section-generated-pipe-src-bus")[0] + fmtBusPipeToggle = c.readFile(f"{c.dir}/templates/section-generated-pipe-src-bus-toggle")[0] 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") @@ -32,7 +32,7 @@ def sectionGeneratedPipes(entity, sub, c): src = pipeSource(key, entity) # Bus. if src.startswith("K."): - src = pipeBusSource(key, c.structure, fmtBusPipe, fmtBusPipeToggle) + src = pipeBusSource(key, entity, src, c.structure, fmtBusPipe, fmtBusPipeToggle) fmtPipe = pipeFormat(fmtExRecent, fmtRecent, fmtSet, fmtToggle, fmtToggleNil, key, entity) for fmt in fmtPipe: diff --git a/Utilities/platform/2/templates/section-generated-pipe-src-bus b/Utilities/platform/2/templates/section-generated-pipe-src-bus new file mode 100644 index 0000000..8ecfb87 --- /dev/null +++ b/Utilities/platform/2/templates/section-generated-pipe-src-bus @@ -0,0 +1,6 @@ +Bus.events.compactMap { Bus.convertKeyValue(%BUS_KEY%, $0) }.map { (k: String, v: %BUS_VALUE_TYPE%) in v } + + + + + diff --git a/Utilities/platform/2/templates/section-generated-pipe-src-bus-toggle b/Utilities/platform/2/templates/section-generated-pipe-src-bus-toggle new file mode 100644 index 0000000..b908dd4 --- /dev/null +++ b/Utilities/platform/2/templates/section-generated-pipe-src-bus-toggle @@ -0,0 +1,6 @@ +Bus.events.compactMap { Bus.convertKeyValue(%BUS_KEY%, $0) }.map { (k: String, v: %BUS_VALUE_TYPE%) in v }.map { _ in } + + + + +