From cea8c2d9ff8ebcff8728d75a19f0ae2e5dfd5224 Mon Sep 17 00:00:00 2001 From: yoichironambu <526475751@qq.com> Date: Sun, 14 Dec 2025 17:48:32 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90AL-1=E3=80=91HELP=5FCONTENTS=20?= =?UTF-8?q?=E3=83=9E=E3=82=AF=E3=83=AD=E3=81=AE=E8=A1=9D=E7=AA=81=E5=95=8F?= =?UTF-8?q?=E9=A1=8C=E3=81=AB=E5=AF=BE=E5=BF=9C=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scripts/generate_solid_designer_commands.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Designer/Data/Scripts/generate_solid_designer_commands.py b/Designer/Data/Scripts/generate_solid_designer_commands.py index a5955d96..6271ada9 100644 --- a/Designer/Data/Scripts/generate_solid_designer_commands.py +++ b/Designer/Data/Scripts/generate_solid_designer_commands.py @@ -19,6 +19,13 @@ from pathlib import Path from typing import List, Dict, Set +# 避免与 Windows 头文件中的宏冲突(例如 HELP_CONTENTS) +# Windows ヘッダのマクロ衝突を回避(例:HELP_CONTENTS) +WIN32_MACRO_CONFLICTS = { + "HELP_CONTENTS", +} + + print("[DEBUG] argv:", sys.argv) @dataclass @@ -41,6 +48,7 @@ def parse_commands(xml_path: Path) -> List[CommandSpec]: root = tree.getroot() # 兼容两种写法: + # 2通りの書き方に対応: または commands_nodes = [] if root.tag.lower().endswith("commandsconfig"): commands_nodes = root.findall(".//commands/command") @@ -64,6 +72,7 @@ def parse_commands(xml_path: Path) -> List[CommandSpec]: print(f"[WARN] No elements found in '{xml_path}'", file=sys.stderr) # 检查重复 id + # 重複する id をチェック seen_ids: Set[str] = set() duplicates: Set[str] = set() for c in specs: @@ -77,6 +86,7 @@ def parse_commands(xml_path: Path) -> List[CommandSpec]: sys.exit(1) # 排序:按 id 排一下,保证生成文件稳定 + # ソート:id で並べて生成結果を安定化 specs.sort(key=lambda c: c.id) return specs @@ -91,6 +101,7 @@ def id_to_const_name(cmd_id: str) -> str: result_chars.append(ch.upper()) else: # '.' '-' ' ' 等全部归一成 '_' + # '.' '-' ' ' などはすべて '_' に正規化 result_chars.append('_') name = "".join(result_chars) @@ -108,6 +119,11 @@ def id_to_const_name(cmd_id: str) -> str: if name and name[0].isdigit(): name = "CMD_" + name + # 避免与 Windows 宏冲突(如 HELP_CONTENTS) + # Windows マクロ衝突を回避(例:HELP_CONTENTS) + if name in WIN32_MACRO_CONFLICTS and not name.startswith("CMD_"): + name = "CMD_" + name + if not name: raise ValueError(f"Cannot convert command id '{cmd_id}' to a valid C++ name")