From 680edf971dd8f775d1549eb5a075ffa8e7b91925 Mon Sep 17 00:00:00 2001 From: Drew T <50529377+Druthulu@users.noreply.github.com> Date: Thu, 1 Oct 2026 17:50:11 -0600 Subject: [PATCH] T3.c4: restruct: --only TU:FN names one body --- decomp-architect/corpus/tools/P10/restruct.py | 7 +++++-- tools/restruct.py | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/decomp-architect/corpus/tools/P10/restruct.py b/decomp-architect/corpus/tools/P10/restruct.py index 4719c9cc22..a11f0b036f 100644 --- a/decomp-architect/corpus/tools/P10/restruct.py +++ b/decomp-architect/corpus/tools/P10/restruct.py @@ -3348,7 +3348,9 @@ def matches_only(only, tu, unit, extra=()): if not only: return True hay = [tu, unit] + list(extra) - globs = [o for o in only if any(c in o for c in "*?[")] # P39 T3: `ov_*` against the alias / src dir (and the path) + if tu and unit and f"{tu}:{unit}" in only: # T3.c4: `TU:FN` names one body (overlay fn names repeat) + return True + globs =[o for o in only if any(c in o for c in "*?[")] # P39 T3: `ov_*` against the alias / src dir (and the path) if globs and tu and any(fnmatch.fnmatchcase(tu, o) or (tu.startswith("src/") and fnmatch.fnmatchcase(tu.split("/")[1], o)) for o in globs): return True return any(o == h or h.endswith("/" + o) or h.startswith("src/" + o + "/") or ("/" + o + "/") in h @@ -4694,7 +4696,8 @@ def selftest(real=False): ok("respell_edit: a lower-precedence p or a non-literal k stays raw", respell_edit("*(s32 *)(a << 2 + 4)", "*(s32 *)(a << 2 + 4)", dict(form="P", pos=0, end=20, base=None, off=4), "SIGN") is None and respell_edit("*(s32 *)(a + i)", "*(s32 *)(a + i)", dict(form="P", pos=0, end=15, base="a", off=0), "SIGN") is None) ok("--only glob: ov_* matches the src dir, not main", matches_only(["ov_*"], "src/ov_SC05_010/x.c", "f") and not matches_only(["ov_*"], "src/main/x.c", "f") - and matches_only(["src/ov_SC05_010/x.c"], "src/ov_SC05_010/x.c", "f")) + and matches_only(["src/ov_SC05_010/x.c"], "src/ov_SC05_010/x.c", "f") + and matches_only(["src/a/x.c:func_1"], "src/a/x.c", "func_1") and not matches_only(["src/a/x.c:func_1"], "src/b/y.c", "func_1")) # ---- rung D on the fixture DEFS_OVERRIDE = {"fx_callee": [("src/ov/fx_defs.c", "void", "s32 a0, s32 a1", False)], "fx_kr": [("src/ov/fx_defs.c", "s32", "s32 a, s32 b", True)]} units = d_units(tu, text) diff --git a/tools/restruct.py b/tools/restruct.py index 4719c9cc22..a11f0b036f 100644 --- a/tools/restruct.py +++ b/tools/restruct.py @@ -3348,7 +3348,9 @@ def matches_only(only, tu, unit, extra=()): if not only: return True hay = [tu, unit] + list(extra) - globs = [o for o in only if any(c in o for c in "*?[")] # P39 T3: `ov_*` against the alias / src dir (and the path) + if tu and unit and f"{tu}:{unit}" in only: # T3.c4: `TU:FN` names one body (overlay fn names repeat) + return True + globs =[o for o in only if any(c in o for c in "*?[")] # P39 T3: `ov_*` against the alias / src dir (and the path) if globs and tu and any(fnmatch.fnmatchcase(tu, o) or (tu.startswith("src/") and fnmatch.fnmatchcase(tu.split("/")[1], o)) for o in globs): return True return any(o == h or h.endswith("/" + o) or h.startswith("src/" + o + "/") or ("/" + o + "/") in h @@ -4694,7 +4696,8 @@ def selftest(real=False): ok("respell_edit: a lower-precedence p or a non-literal k stays raw", respell_edit("*(s32 *)(a << 2 + 4)", "*(s32 *)(a << 2 + 4)", dict(form="P", pos=0, end=20, base=None, off=4), "SIGN") is None and respell_edit("*(s32 *)(a + i)", "*(s32 *)(a + i)", dict(form="P", pos=0, end=15, base="a", off=0), "SIGN") is None) ok("--only glob: ov_* matches the src dir, not main", matches_only(["ov_*"], "src/ov_SC05_010/x.c", "f") and not matches_only(["ov_*"], "src/main/x.c", "f") - and matches_only(["src/ov_SC05_010/x.c"], "src/ov_SC05_010/x.c", "f")) + and matches_only(["src/ov_SC05_010/x.c"], "src/ov_SC05_010/x.c", "f") + and matches_only(["src/a/x.c:func_1"], "src/a/x.c", "func_1") and not matches_only(["src/a/x.c:func_1"], "src/b/y.c", "func_1")) # ---- rung D on the fixture DEFS_OVERRIDE = {"fx_callee": [("src/ov/fx_defs.c", "void", "s32 a0, s32 a1", False)], "fx_kr": [("src/ov/fx_defs.c", "s32", "s32 a, s32 b", True)]} units = d_units(tu, text)