summaryrefslogtreecommitdiffstats
path: root/scripts/gen_registry.py
diff options
context:
space:
mode:
authorEthan Werner <mail@ethanwerner.com>2026-08-09 15:02:21 +0400
committerEthan Werner <mail@ethanwerner.com>2026-08-09 15:02:21 +0400
commit3d92926a902017e7cf1f5738e99ff62da596ce12 (patch)
tree2b55422c26a48759d56fa91f06df24449e9dfa88 /scripts/gen_registry.py
parent07e18043145f3d91c8ea7ec3ad41b3c905585277 (diff)
Diffstat (limited to 'scripts/gen_registry.py')
-rw-r--r--scripts/gen_registry.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/scripts/gen_registry.py b/scripts/gen_registry.py
index e80759e..dbe6f04 100644
--- a/scripts/gen_registry.py
+++ b/scripts/gen_registry.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
"""Generate ts_registry_generated.c with registry array and getter functions."""
+import glob
import importlib.util
import os
import re
@@ -39,9 +40,9 @@ def _resolve_params_size(params_size, name):
return params_size
except FileNotFoundError:
pass
- # Struct not in header, compute size from definition
- import glob
-
+ # Struct not in header, compute size from definition.
+ # Both fp_t (double) and uint_t (uint64_t) are 8 bytes on 64-bit.
+ # This is a fallback; sizeof() in the generated C code is preferred.
lib_dir = os.path.join(ROOT, "lib")
for cfile in glob.glob(os.path.join(lib_dir, "*.c")):
try:
@@ -57,7 +58,11 @@ def _resolve_params_size(params_size, name):
body = struct_m.group(1)
n_fp = len(re.findall(r"fp_t\s+", body))
n_uint = len(re.findall(r"uint_t\s+", body))
- return str(n_fp * 8 + n_uint * 8)
+ n_total = n_fp + n_uint
+ if n_total == 0:
+ return "0"
+ # Assume 8-byte alignment (valid for fp_t=double, uint_t=uint64_t)
+ return str(n_total * 8)
return "0"