mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-05 18:58:57 +03:00
feat(skd): TypeSet (композитный тип-набор) в valueType параметра
Параметры типа «исключаемые документы» имеют valueType с <v8:TypeSet xmlns:dN="...">dN:DocumentRef</v8:TypeSet> — указывает на все ссылки указанного класса конфигурации, а не на конкретный объект. Раньше теряли целиком: decompile читал только <v8:Type>, compile эмитил голое имя как <v8:Type>DocumentRef</v8:Type> (что не валидно). DSL — голое имя ref-класса без точки (CatalogRef, DocumentRef, EnumRef, ChartOfAccountsRef, ChartOfCharacteristicTypesRef, ChartOfCalculationTypesRef, BusinessProcessRef, TaskRef, ExchangePlanRef, InformationRegisterRef, AnyRef) → TypeSet. С точкой (DocumentRef.X) — конкретный Ref как было. decompile: Get-ValueTypeShorthand читает v8:TypeSet и сохраняет local-name (после prefix:). compile (PS+Py): Emit-SingleValueType распознаёт голое имя из набора и эмитит <v8:TypeSet xmlns:d5p1=...>d5p1:NAME</v8:TypeSet>. Sample30 total: 618 → 607 строк diff.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# skd-compile v1.97 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.98 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$DefinitionFile,
|
||||
@@ -336,6 +336,14 @@ function Emit-SingleValueType {
|
||||
return
|
||||
}
|
||||
|
||||
# TypeSet (композитный тип-набор): голое имя без точки, типа DocumentRef / CatalogRef /
|
||||
# EnumRef / ChartOfAccountsRef / etc. (все ссылки указанного класса).
|
||||
# Эмитим <v8:TypeSet xmlns:dN="..."> вместо <v8:Type>.
|
||||
if ($typeStr -match '^(CatalogRef|DocumentRef|EnumRef|ChartOfAccountsRef|ChartOfCharacteristicTypesRef|ChartOfCalculationTypesRef|BusinessProcessRef|TaskRef|ExchangePlanRef|InformationRegisterRef|AnyRef)$') {
|
||||
X "$indent<v8:TypeSet xmlns:d5p1=`"http://v8.1c.ru/8.1/data/enterprise/current-config`">d5p1:$(Esc-Xml $typeStr)</v8:TypeSet>"
|
||||
return
|
||||
}
|
||||
|
||||
# Fallback — assume dot-qualified types are also config references
|
||||
if ($typeStr.Contains('.')) {
|
||||
X "$indent<v8:Type xmlns:d5p1=`"http://v8.1c.ru/8.1/data/enterprise/current-config`">d5p1:$(Esc-Xml $typeStr)</v8:Type>"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# skd-compile v1.97 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.98 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import json
|
||||
@@ -214,6 +214,11 @@ def emit_single_value_type(lines, type_str, indent):
|
||||
lines.append(f'{indent}<v8:Type xmlns:d5p1="http://v8.1c.ru/8.1/data/enterprise/current-config">d5p1:{esc_xml(type_str)}</v8:Type>')
|
||||
return
|
||||
|
||||
# TypeSet (композитный тип-набор): голое имя без точки.
|
||||
if re.match(r'^(CatalogRef|DocumentRef|EnumRef|ChartOfAccountsRef|ChartOfCharacteristicTypesRef|ChartOfCalculationTypesRef|BusinessProcessRef|TaskRef|ExchangePlanRef|InformationRegisterRef|AnyRef)$', type_str):
|
||||
lines.append(f'{indent}<v8:TypeSet xmlns:d5p1="http://v8.1c.ru/8.1/data/enterprise/current-config">d5p1:{esc_xml(type_str)}</v8:TypeSet>')
|
||||
return
|
||||
|
||||
# Fallback -- assume dot-qualified types are also config references
|
||||
if '.' in type_str:
|
||||
lines.append(f'{indent}<v8:Type xmlns:d5p1="http://v8.1c.ru/8.1/data/enterprise/current-config">d5p1:{esc_xml(type_str)}</v8:Type>')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# skd-decompile v0.80 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
||||
# skd-decompile v0.81 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -335,12 +335,19 @@ function Get-ValueTypeShorthand {
|
||||
param($valueTypeNode)
|
||||
if (-not $valueTypeNode) { return $null }
|
||||
$types = $valueTypeNode.SelectNodes("v8:Type", $ns)
|
||||
if ($types.Count -eq 0) { return $null }
|
||||
$typeSets = $valueTypeNode.SelectNodes("v8:TypeSet", $ns)
|
||||
if ($types.Count -eq 0 -and $typeSets.Count -eq 0) { return $null }
|
||||
$qualN = $valueTypeNode.SelectSingleNode("v8:NumberQualifiers", $ns)
|
||||
$qualS = $valueTypeNode.SelectSingleNode("v8:StringQualifiers", $ns)
|
||||
$qualD = $valueTypeNode.SelectSingleNode("v8:DateQualifiers", $ns)
|
||||
$shorts = @()
|
||||
foreach ($t in $types) { $shorts += (Get-OneTypeShorthand -typeNode $t -qualNumber $qualN -qualString $qualS -qualDate $qualD) }
|
||||
# TypeSet (композитный тип-набор) — извлекаем local-name из значения "<prefix>:Name".
|
||||
foreach ($ts in $typeSets) {
|
||||
$txt = $ts.InnerText
|
||||
if ($txt -match ':(.+)$') { $shorts += $matches[1] }
|
||||
else { $shorts += $txt }
|
||||
}
|
||||
if ($shorts.Count -eq 1) { return $shorts[0] }
|
||||
return ,$shorts
|
||||
}
|
||||
|
||||
@@ -176,9 +176,12 @@
|
||||
| `EnumRef.XXX` | `d5p1:EnumRef.XXX` | inline xmlns:d5p1 |
|
||||
| `ChartOfAccountsRef.XXX` | `d5p1:ChartOfAccountsRef.XXX` | inline xmlns:d5p1 |
|
||||
| `StandardPeriod` | `v8:StandardPeriod` | — |
|
||||
| `DocumentRef` (без `.XXX`) | `<v8:TypeSet xmlns:d5p1=...>d5p1:DocumentRef</v8:TypeSet>` | композитный тип-набор (все ссылки указанного класса) |
|
||||
|
||||
> **Ссылочные типы** (`CatalogRef.XXX`, `DocumentRef.XXX` и др.) эмитируются с inline namespace declaration: `<v8:Type xmlns:d5p1="http://v8.1c.ru/8.1/data/enterprise/current-config">d5p1:CatalogRef.XXX</v8:Type>`. Использование префикса `cfg:` вместо `d5p1:` с объявлением namespace приводит к ошибке XDTO. Сборка EPF со ссылочными типами требует базу с соответствующей конфигурацией (не пустую).
|
||||
|
||||
> **TypeSet (тип-набор)** — голое имя без точки (`CatalogRef`, `DocumentRef`, `EnumRef`, `ChartOfAccountsRef`, `ChartOfCharacteristicTypesRef`, `ChartOfCalculationTypesRef`, `BusinessProcessRef`, `TaskRef`, `ExchangePlanRef`, `InformationRegisterRef`, `AnyRef`) — указывает на **все** ссылки этого класса конфигурации (а не на конкретный объект). Эмитится как `<v8:TypeSet>` вместо `<v8:Type>`. Используется в параметрах типа «исключаемые документы» и подобных.
|
||||
|
||||
### Синонимы типов
|
||||
|
||||
Все имена типов регистронезависимые. Поддерживаются русские и альтернативные имена:
|
||||
|
||||
Reference in New Issue
Block a user