From 4653abd6539a60847cacfbe735a53240f7c8f0e9 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Sun, 18 Oct 2026 15:48:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(phase1):=20typedef=20=E6=94=B6=E9=9B=86?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=20Markers=20=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit typedef LONG = int32 等新语法不再依赖 CTypedef 文本标记,LONG 能正确进入 typedef_map 并解析为 int32。 --- lib/Projectrans/Phase1Generator.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Projectrans/Phase1Generator.py b/lib/Projectrans/Phase1Generator.py index a54ca7a..56c1c0a 100644 --- a/lib/Projectrans/Phase1Generator.py +++ b/lib/Projectrans/Phase1Generator.py @@ -381,7 +381,11 @@ class Phase1Generator: if isinstance(node, ast.AnnAssign) and isinstance(node.target, ast.Name): var_name: str = node.target.id is_typedef: bool = False - if isinstance(node.annotation, ast.Attribute) and hasattr(node.annotation, 'attr') and node.annotation.attr == 'CTypedef': + _Markers: tuple[str, ...] = (tuple(getattr(node, 'Markers', None) or ()) + + tuple(getattr(node.annotation, 'Markers', None) or ())) + if 'typedef' in _Markers: + is_typedef = True + elif isinstance(node.annotation, ast.Attribute) and hasattr(node.annotation, 'attr') and node.annotation.attr == 'CTypedef': is_typedef = True elif isinstance(node.annotation, ast.Name) and node.annotation.id == 'CTypedef': is_typedef = True