mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-09-17 23:35:22 +03:00
feat(meta-compile,meta-decompile): поддержка типа Enum (Перечисления) (v1.51/v0.42)
13-й тип. Рерайт Emit-EnumProperties на общие хелперы (был легаси-хардкод:
Comment/UseStandardCommands/ChoiceMode/формы/презентации/ChoiceHistoryOnInput).
Emit-EnumValue + comment; Parse-EnumValueShorthand больше не стрингифаит synonym
(строка|{ru,en}). Декомпилятор: снят гейт +Enum; захват EnumValue (values,
короткая строка|объект name/synonym/comment); StandardAttributes register-style
opt-out (блок Order/Ref present 85%, absent → standardAttributes:"").
Class-2 фиксы дефолтов (тип-зависимые, декомпилятор зеркалит компилятор):
- useStandardCommands: у Enum дефолт false (не true)
- quickChoice: у Enum дефолт true (не false)
- пустой <Synonym/> значения ≠ авто-синоним → synonym:"" (аналог object-level фикса)
ПОЛНЫЙ КОРПУС 2545 (acc+erp): match 2545/2545, TOTAL 0, 0 крашей — byte-exact,
order-preserved (сверено с реальными 1С-файлами modulo trailing newline+GUID).
Регресс 50/50 ps1+py, ps1==py identical. spec §7.3, кейс enum-full.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
de2e966311
commit
117a06ff3e
@@ -1,4 +1,4 @@
|
||||
# meta-compile v1.50 — Compile 1C metadata object from JSON
|
||||
# meta-compile v1.51 — Compile 1C metadata object from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -868,7 +868,7 @@ function Parse-EnumValueShorthand {
|
||||
$name = "$($val.name)"
|
||||
return @{
|
||||
name = $name
|
||||
synonym = if ($val.synonym) { "$($val.synonym)" } else { Split-CamelCase $name }
|
||||
synonym = if ($null -ne $val.synonym) { $val.synonym } else { Split-CamelCase $name } # строка ИЛИ {ru,en} → Emit-MLText
|
||||
comment = if ($val.comment) { "$($val.comment)" } else { "" }
|
||||
}
|
||||
}
|
||||
@@ -1864,7 +1864,7 @@ function Emit-EnumValue {
|
||||
X "$indent`t<Properties>"
|
||||
X "$indent`t`t<Name>$(Esc-Xml $parsed.name)</Name>"
|
||||
Emit-MLText "$indent`t`t" "Synonym" $parsed.synonym
|
||||
X "$indent`t`t<Comment/>"
|
||||
if ($parsed.comment) { X "$indent`t`t<Comment>$(Esc-XmlText $parsed.comment)</Comment>" } else { X "$indent`t`t<Comment/>" }
|
||||
X "$indent`t</Properties>"
|
||||
X "$indent</EnumValue>"
|
||||
}
|
||||
@@ -2246,23 +2246,24 @@ function Emit-EnumProperties {
|
||||
|
||||
X "$i<Name>$(Esc-Xml $objName)</Name>"
|
||||
Emit-MLText $i "Synonym" $synonym
|
||||
X "$i<Comment/>"
|
||||
X "$i<UseStandardCommands>false</UseStandardCommands>"
|
||||
if ($def.comment) { X "$i<Comment>$(Esc-XmlText $def.comment)</Comment>" } else { X "$i<Comment/>" }
|
||||
$useStdCmds = if (Get-BoolProp "useStandardCommands" $false) { "true" } else { "false" }
|
||||
X "$i<UseStandardCommands>$useStdCmds</UseStandardCommands>"
|
||||
|
||||
Emit-StandardAttributes $i "Enum"
|
||||
X "$i<Characteristics/>"
|
||||
Emit-Characteristics $i $def.characteristics
|
||||
|
||||
$quickChoice = if ($def.quickChoice -eq $false) { "false" } else { "true" }
|
||||
X "$i<QuickChoice>$quickChoice</QuickChoice>"
|
||||
X "$i<ChoiceMode>BothWays</ChoiceMode>"
|
||||
X "$i<DefaultListForm/>"
|
||||
X "$i<DefaultChoiceForm/>"
|
||||
X "$i<AuxiliaryListForm/>"
|
||||
X "$i<AuxiliaryChoiceForm/>"
|
||||
X "$i<ListPresentation/>"
|
||||
X "$i<ExtendedListPresentation/>"
|
||||
X "$i<Explanation/>"
|
||||
X "$i<ChoiceHistoryOnInput>Auto</ChoiceHistoryOnInput>"
|
||||
X "$i<ChoiceMode>$(Get-EnumProp 'ChoiceMode' 'choiceMode' 'BothWays')</ChoiceMode>"
|
||||
Emit-FormRef $i "DefaultListForm" $def.defaultListForm
|
||||
Emit-FormRef $i "DefaultChoiceForm" $def.defaultChoiceForm
|
||||
Emit-FormRef $i "AuxiliaryListForm" $def.auxiliaryListForm
|
||||
Emit-FormRef $i "AuxiliaryChoiceForm" $def.auxiliaryChoiceForm
|
||||
Emit-MLText $i "ListPresentation" $def.listPresentation
|
||||
Emit-MLText $i "ExtendedListPresentation" $def.extendedListPresentation
|
||||
Emit-MLText $i "Explanation" $def.explanation
|
||||
X "$i<ChoiceHistoryOnInput>$(Get-EnumProp 'ChoiceHistoryOnInput' 'choiceHistoryOnInput' 'Auto')</ChoiceHistoryOnInput>"
|
||||
}
|
||||
|
||||
function Emit-ConstantProperties {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# meta-compile v1.50 — Compile 1C metadata object from JSON
|
||||
# meta-compile v1.51 — Compile 1C metadata object from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
|
||||
import argparse
|
||||
@@ -891,7 +891,8 @@ def parse_enum_value_shorthand(val):
|
||||
name = str(val.get('name', ''))
|
||||
return {
|
||||
'name': name,
|
||||
'synonym': str(val['synonym']) if val.get('synonym') else split_camel_case(name),
|
||||
# строка ИЛИ {ru,en} → emit_mltext; None → авто из имени
|
||||
'synonym': val['synonym'] if val.get('synonym') is not None else split_camel_case(name),
|
||||
'comment': str(val['comment']) if val.get('comment') else '',
|
||||
}
|
||||
|
||||
@@ -1915,7 +1916,10 @@ def emit_enum_value(indent, parsed):
|
||||
X(f'{indent}\t<Properties>')
|
||||
X(f'{indent}\t\t<Name>{esc_xml(parsed["name"])}</Name>')
|
||||
emit_mltext(f'{indent}\t\t', 'Synonym', parsed['synonym'])
|
||||
X(f'{indent}\t\t<Comment/>')
|
||||
if parsed.get('comment'):
|
||||
X(f'{indent}\t\t<Comment>{esc_xml_text(parsed["comment"])}</Comment>')
|
||||
else:
|
||||
X(f'{indent}\t\t<Comment/>')
|
||||
X(f'{indent}\t</Properties>')
|
||||
X(f'{indent}</EnumValue>')
|
||||
|
||||
@@ -2248,21 +2252,25 @@ def emit_enum_properties(indent):
|
||||
i = indent
|
||||
X(f'{i}<Name>{esc_xml(obj_name)}</Name>')
|
||||
emit_mltext(i, 'Synonym', synonym)
|
||||
X(f'{i}<Comment/>')
|
||||
X(f'{i}<UseStandardCommands>false</UseStandardCommands>')
|
||||
if defn.get('comment'):
|
||||
X(f'{i}<Comment>{esc_xml_text(defn["comment"])}</Comment>')
|
||||
else:
|
||||
X(f'{i}<Comment/>')
|
||||
use_std_cmds = 'true' if get_bool_prop('useStandardCommands', False) else 'false'
|
||||
X(f'{i}<UseStandardCommands>{use_std_cmds}</UseStandardCommands>')
|
||||
emit_standard_attributes(i, 'Enum')
|
||||
X(f'{i}<Characteristics/>')
|
||||
emit_characteristics(i, defn.get('characteristics'))
|
||||
quick_choice = 'false' if defn.get('quickChoice') is False else 'true'
|
||||
X(f'{i}<QuickChoice>{quick_choice}</QuickChoice>')
|
||||
X(f'{i}<ChoiceMode>BothWays</ChoiceMode>')
|
||||
X(f'{i}<DefaultListForm/>')
|
||||
X(f'{i}<DefaultChoiceForm/>')
|
||||
X(f'{i}<AuxiliaryListForm/>')
|
||||
X(f'{i}<AuxiliaryChoiceForm/>')
|
||||
X(f'{i}<ListPresentation/>')
|
||||
X(f'{i}<ExtendedListPresentation/>')
|
||||
X(f'{i}<Explanation/>')
|
||||
X(f'{i}<ChoiceHistoryOnInput>Auto</ChoiceHistoryOnInput>')
|
||||
X(f'{i}<ChoiceMode>{get_enum_prop("ChoiceMode", "choiceMode", "BothWays")}</ChoiceMode>')
|
||||
emit_form_ref(i, 'DefaultListForm', defn.get('defaultListForm'))
|
||||
emit_form_ref(i, 'DefaultChoiceForm', defn.get('defaultChoiceForm'))
|
||||
emit_form_ref(i, 'AuxiliaryListForm', defn.get('auxiliaryListForm'))
|
||||
emit_form_ref(i, 'AuxiliaryChoiceForm', defn.get('auxiliaryChoiceForm'))
|
||||
emit_mltext(i, 'ListPresentation', defn.get('listPresentation'))
|
||||
emit_mltext(i, 'ExtendedListPresentation', defn.get('extendedListPresentation'))
|
||||
emit_mltext(i, 'Explanation', defn.get('explanation'))
|
||||
X(f'{i}<ChoiceHistoryOnInput>{get_enum_prop("ChoiceHistoryOnInput", "choiceHistoryOnInput", "Auto")}</ChoiceHistoryOnInput>')
|
||||
|
||||
def emit_constant_properties(indent):
|
||||
i = indent
|
||||
|
||||
Reference in New Issue
Block a user