fix(extern): worker 合并 sig_files 补全 extern 集合

共享 export_extern_funcs 可能因 sig_files 过滤缺少 include 模块(win32process.ReadProcessMemory 等);worker 内从 sig_files 合并补全。
This commit is contained in:
TermiNexus committed 2026-10-19 14:55:48 +08:00
1 parent 8b5bbbc417
commit ed76f77218
1 file changed
+14 -1
+14 -1
View File
@@ -2392,7 +2392,20 @@ class Phase2Translator:
trans.translator._source_module_sig_files = self._shared_source_module_sig_files
trans.translator._all_define_constants = self._shared_all_dc
trans.translator._define_decl_types = self._shared_all_decl_types
trans.translator._export_extern_funcs = self._shared_export_extern_funcs
# 共享集合可能因 sig_files 过滤而缺少 include 模块的 extern 声明;
# 这里从本 translator 的 sig_files 合并补全(跨模块 extern 必须裸名)。
_combined_extern: dict[str, str] = dict(self._shared_export_extern_funcs)
for _sha1_key, _sig_path in self.sig_files.items():
try:
_, _sig_tree = parse_python_file(_sig_path)
if _sig_tree is None:
continue
for _node in ast.iter_child_nodes(_sig_tree):
if isinstance(_node, ast.FunctionDef) and _IsExportExternFuncNode(_node):
_combined_extern[_node.name] = _sha1_key
except Exception:
continue
trans.translator._export_extern_funcs = _combined_extern
if self._shared_generic_class_templates:
if not hasattr(trans.translator.ClassHandler, '_generic_class_templates'):
trans.translator.ClassHandler._generic_class_templates = {}