fix(roadmap): credit a base method the emulator has on the object's own type

A script call ANIMO^GETNAME is served by AnimoVariable's own GETNAME, so
it no longer counts toward the missing base `*` GETNAME.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Patryk Gensch
2026-10-28 20:38:23 +01:00
co-authored by Claude Opus 5.5
parent 60a2c65e1f
commit f71cd9a90f
2 changed files with 9 additions and 5 deletions
+5 -2
View File
@@ -43,7 +43,8 @@ def usage_index(usage: dict, types: dict) -> tuple[dict, dict, dict]:
kind is method / event / field / object. Within a title the build with the most places kind is method / event / field / object. Within a title the build with the most places
counts, so several releases of one game are one title; places then add up across titles. counts, so several releases of one game are one title; places then add up across titles.
A method of the base runner resolves to `*`; a call whose target object is unknown counts A method of the base runner resolves to `*`, unless the emulator has it on the object's own
type (then that type serves the call); a call whose target object is unknown counts
for the scope that has the method when exactly one does (or `*`). Returns the index, the for the scope that has the method when exactly one does (or `*`). Returns the index, the
direct usage the original's known API does not explain (keyed by the script's type name), direct usage the original's known API does not explain (keyed by the script's type name),
and the number of builds and titles counted. and the number of builds and titles counted.
@@ -52,6 +53,7 @@ def usage_index(usage: dict, types: dict) -> tuple[dict, dict, dict]:
known = {name: {"method": {m["name"] for m in t["methods"] if m["original"]}, known = {name: {"method": {m["name"] for m in t["methods"] if m["original"]},
"event": {e["name"] for e in t.get("events", [])}, "event": {e["name"] for e in t.get("events", [])},
"field": {f["name"] for f in t.get("fields", [])}} for name, t in types.items()} "field": {f["name"] for f in t.get("fields", [])}} for name, t in types.items()}
emulated = {name: {m["name"] for m in t["methods"] if m["status"] != "missing"} for name, t in types.items()}
base = known.get("*", {}).get("method", set()) base = known.get("*", {}).get("method", set())
owners = defaultdict(set) owners = defaultdict(set)
for scope, names in known.items(): for scope, names in known.items():
@@ -67,7 +69,8 @@ def usage_index(usage: dict, types: dict) -> tuple[dict, dict, dict]:
if scope in HIDDEN: if scope in HIDDEN:
continue continue
for name, count in names.items(): for name, count in names.items():
if scope and name in known[scope][kind]: if scope and (name in known[scope][kind] or # a base method the emulator has on this type
kind == "method" and name in base and name in emulated[scope]):
places[(scope, kind, name)] += count places[(scope, kind, name)] += count
elif kind == "method" and name in base: elif kind == "method" and name in base:
places[("*", kind, name)] += count places[("*", kind, name)] += count
+4 -3
View File
@@ -72,11 +72,12 @@ def test_roadmap_orders_gaps_by_games_that_use_them():
{"name": "CANVAS_OBSERVER", "methods": [ {"name": "CANVAS_OBSERVER", "methods": [
{"name": "REDRAW", "status": "missing", "original": [{"binary_id": "a"}]}, {"name": "REDRAW", "status": "missing", "original": [{"binary_id": "a"}]},
{"name": "SAVE", "status": "missing", "original": [{"binary_id": "a"}]}, {"name": "SAVE", "status": "missing", "original": [{"binary_id": "a"}]},
{"name": "ADD", "status": "registered", "original": [{"binary_id": "a"}]}], {"name": "ADD", "status": "registered", "original": [{"binary_id": "a"}]},
{"name": "GETNAME", "status": "registered", "original": []}], # the emulator's own override
"events": [{"name": "ONUPDATE", "status": "not_found", "original": ["a"]}], "fields": []}]} "events": [{"name": "ONUPDATE", "status": "not_found", "original": ["a"]}], "fields": []}]}
usage = {"builds": [ usage = {"builds": [
build("Gra A", "Piklib 8", objects={"CANVASOBSERVER": 1}, build("Gra A", "Piklib 8", objects={"CANVASOBSERVER": 1},
methods={"CANVASOBSERVER": {"SAVE": 2, "ADD": 9, "PASTE": 1}}, dynamic={"CANVAS_OBSERVER": {"BLUR": 4}}), methods={"CANVASOBSERVER": {"SAVE": 2, "ADD": 9, "PASTE": 1, "GETNAME": 3}}, dynamic={"CANVAS_OBSERVER": {"BLUR": 4}}),
build("Gra A", "Piklib 8", methods={"CANVAS_OBSERVER": {"SAVE": 3}}), # another release: counts once build("Gra A", "Piklib 8", methods={"CANVAS_OBSERVER": {"SAVE": 3}}), # another release: counts once
build("Gra B", "BlooMoo", methods={"CANVAS_OBSERVER": {"SAVE": 1}}, events={"CANVAS_OBSERVER": {"ONUPDATE": 2}}, build("Gra B", "BlooMoo", methods={"CANVAS_OBSERVER": {"SAVE": 1}}, events={"CANVAS_OBSERVER": {"ONUPDATE": 2}},
unresolved={"calls": {"GETNAME": 5}, "reasons": {}, "targets": {}}), unresolved={"calls": {"GETNAME": 5}, "reasons": {}, "targets": {}}),
@@ -85,6 +86,6 @@ def test_roadmap_orders_gaps_by_games_that_use_them():
assert "3 wydań, 2 gier" in text assert "3 wydań, 2 gier" in text
assert "`SAVE` (8) — gry: 2, miejsca: 4; `REDRAW` (8) — nieużywane" in text assert "`SAVE` (8) — gry: 2, miejsca: 4; `REDRAW` (8) — nieużywane" in text
assert "| CANVAS_OBSERVER | `SAVE` | metoda | 2 | 4 | 8 |" in text assert "| CANVAS_OBSERVER | `SAVE` | metoda | 2 | 4 | 8 |" in text
assert "| * | `GETNAME` | metoda | 1 | 5 | 8 |" in text # unknown target, base method assert "| * | `GETNAME` | metoda | 1 | 5 | 8 |" in text # unknown target, base method; not the override
assert "| CANVASOBSERVER | `PASTE` | metoda | 1 | 1 | 8 |" in text and "BLUR" not in text assert "| CANVASOBSERVER | `PASTE` | metoda | 1 | 1 | 8 |" in text and "BLUR" not in text
assert "Obiekty w skryptach: 1 (gry: 1)." in text assert "Obiekty w skryptach: 1 (gry: 1)." in text