api: lazy format detection (Sniffs.luau): F.detect loads no format module
tools/gen_registry.py now also writes src/Rosetta/Sniffs.luau: each format's sniff copied (tools/sniff_extract.py) with the top-level locals, types and load-time loops it reaches; requires outside core/ become proxies that require on first field access. 198 of 199 sniffs are copied (model/fbx reads Binary.MAGIC at load time: its module sniffs). Registry entries gain sniff (0 copy, 1 copy reaching a codec / container, 2 module) and variant (the module has variant(r)). init.luau detect: the extension's formats first, then by sniff cost and registry order; a sniff runs only while its cap (1, or LATE) could still win, ties to registry order, so results equal the eager path. F.detect loads the winner only when it has variant(). tests/detect.luau: every copied sniff against its module's on samples of every fixture module (tools/fixtures/detect.py), scores within 0..1, and F.detect against the eager reference with no name, the right / wrong / unknown extension and per category. Outside init / Registry / gen_registry: tools/fixtures.py (LAST generators run after the others and rerun when their outputs change), tools/lint_rules.py (Sniffs is api layer, skipped by DUP), docs/STYLE.md and docs/API.md notes, build/ regenerated.
This commit is contained in:
1 parent
dde6be117c
commit
e05392ee8e
18 files changed
+16513
-1466
No files matched your search
+6
-1
@@ -8,6 +8,7 @@
|
||||
# INPUTS = ["tests/fixtures/pngsuite", ...] # optional: files / dirs whose change triggers a rebuild
|
||||
# def generate(ctx): ... # ctx.emit("png_suite", value), ctx.nix("imagemagick", [...]), ...
|
||||
# A generator is skipped while all its outputs are newer than itself and its INPUTS (--force reruns it).
|
||||
# LAST = True runs it after the others; it also reruns when any other generator's output changed (it reads them)
|
||||
#
|
||||
# ctx.emit(name, value): writes tests/gen/<name>.luau returning value. Python values map to Luau: bytes -> string
|
||||
# literal (any bytes), str -> string literal, int / float / bool, list / tuple -> array, dict -> table (string keys
|
||||
@@ -123,12 +124,16 @@ def main():
|
||||
if "--list" in sys.argv:
|
||||
print("\n".join(names))
|
||||
return
|
||||
mods = {name: load(os.path.join(GENERATORS, name + ".py")) for name in names}
|
||||
names.sort(key=lambda n: bool(getattr(mods[n], "LAST", False)))
|
||||
for name in names:
|
||||
if args and not any(a in name for a in args):
|
||||
continue
|
||||
path = os.path.join(GENERATORS, name + ".py")
|
||||
mod = load(path)
|
||||
mod = mods[name]
|
||||
inputs = [path, os.path.abspath(__file__)] + [os.path.join(ROOT, p) for p in getattr(mod, "INPUTS", [])]
|
||||
if getattr(mod, "LAST", False):
|
||||
inputs += [os.path.join(stamps, n) for n in names if n != name and not getattr(mods[n], "LAST", False)]
|
||||
stamp = os.path.join(stamps, name)
|
||||
if not force and os.path.exists(stamp):
|
||||
outs = open(stamp).read().split("\n")
|
||||
|
||||
Reference in new issue
Block a user