Extract Piklib 6.1 methods by name from Runner::run
6.1 has no prepareMthHashSet and no id-switch: CMC_*_Runner::run takes the method *name* (CXString) and dispatches via a `CXString(tmp,"name"); equalsIgnoreCase(name)` chain. extract_methods now falls back (only when the hashset pass finds nothing) to scanning run() for that pattern, recovering the names (no numeric ids). 6.1 now yields 186 methods (Animo: show/hide/play/setFPS/...); dispatch stays 0 since the string chain isn't a jump table. 7.1/8.x untouched (they have prepareMthHashSet). Note: 6.1 names are camelCase/lowercase vs 7.1+ UPPERCASE (engine compares case- insensitively), so a cross-version method diff needs case folding to be clean. 38/38 tests (test_versions updated: 6.1 methods present with id=None). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -30,9 +30,13 @@ def test_piklib61_early_engine_partial_surface():
|
||||
names = {t["script_name"] for t in s.types}
|
||||
assert len(names) >= 20 and {"ANIMO", "ARRAY", "BUTTON"} <= names
|
||||
assert all(t.get("cpp_class") is None or t["cpp_class"].startswith("CMC_") for t in s.types)
|
||||
# events + script fields work; method registration (prepareMthHashSet) doesn't exist yet
|
||||
assert s.events and s.fields
|
||||
assert s.methods == [] and s.method_dispatch == []
|
||||
# 6.1 predates prepareMthHashSet: methods are dispatched by NAME in run(), so they're
|
||||
# recovered without numeric ids, and the id-switch dispatch axis stays empty.
|
||||
assert s.methods and all(m["id"] is None for m in s.methods)
|
||||
assert s.method_dispatch == []
|
||||
animo = {m["name"] for m in s.methods if m["owner"] == "CMC_Animo"}
|
||||
assert {"show", "hide", "play"} <= animo # 6.1 uses lower/camelCase names
|
||||
|
||||
|
||||
def test_piklib71_full_surface():
|
||||
@@ -43,10 +47,12 @@ def test_piklib71_full_surface():
|
||||
assert sum(1 for t in s.types if t.get("cpp_class")) > len(s.types) // 2
|
||||
|
||||
|
||||
def test_61_to_71_diff_adds_methods():
|
||||
def test_61_to_71_method_id_evolution():
|
||||
s61, s71 = _load(P61), _load(P71)
|
||||
shared = {t["script_name"] for t in s61.types} & {t["script_name"] for t in s71.types}
|
||||
assert {"ANIMO", "ARRAY", "BUTTON"} <= shared # stable core across the two early versions
|
||||
# 7.1 introduces the registered-method machinery 6.1 lacked entirely
|
||||
d = compute_diff(s61, s71)
|
||||
assert len(d["methods"]["added"]) > 100 and d["methods"]["removed"] == []
|
||||
assert {"ANIMO", "ARRAY", "BUTTON"} <= shared # stable type core across the two early versions
|
||||
# both expose a rich method surface, but only 7.1 carries numeric ids (prepareMthHashSet);
|
||||
# 6.1's are name-only. (Names also differ in case - 6.1 camelCase vs 7.1 UPPERCASE - which is
|
||||
# why a raw method diff is noisy without case folding.)
|
||||
assert len(s61.methods) > 100 and all(m["id"] is None for m in s61.methods)
|
||||
assert len(s71.methods) > 100 and all(m["id"] is not None for m in s71.methods)
|
||||
|
||||
Reference in New Issue
Block a user