Commit 2450c75
committed
fix(python): extend CF_RULE struct layout to match fm_cf_rule_t
The Python wheel drives formulon_capi.wasm through wasmtime using a
hand-mirrored byte layout of the C ABI structs. CF_RULE in
packages/python/formulon/_structs.py was defined before fm_cf_rule_t
gained ColorScale/DataBar/IconSet fields, leaving the Python struct at
88 bytes against the real 168-byte C struct. alloc_struct(LIB,
S.CF_RULE) therefore allocated a WASM-linear-memory buffer 80 bytes too
small for what fm_sheet_cf_add_rule/fm_sheet_cf_get_at actually
read/write, corrupting the round-tripped type field (and potentially
nearby WASM heap state) and failing
test_cf_add_get_evaluate_clear ("0 != 1").
- Add CFVO_BLOB and CF_COLOR_BLOB opaque blob primitives, following the
existing VALUE_BLOB precedent, for the by-value-embedded fm_cfvo_t
and fm_cf_color_t sub-structs
- Generalize Struct.unpack()'s opaque-blob skip from the hardcoded
"blob16" check to "kind not in _FMT" so future blob kinds don't need
another hardcoded name
- Extend CF_RULE's field list with every field fm_cf_rule_t gained:
color_scale_thresholds/colors/count, data_bar_engaged,
data_bar_min/max (CFVO_BLOB), data_bar_fill (CF_COLOR_BLOB),
data_bar_show_value, data_bar_min/max_length_pct, icon_set_engaged,
icon_set_name, icon_set_thresholds, icon_set_threshold_count,
icon_set_reverse, icon_set_show_value, icon_set_percent, in the
declared order of src/c_api/formulon_c.h. Struct's existing
alignment-rounding reproduces the C compiler's inter-field padding
automatically; total size now correctly computes to 168 bytes
- Update the stale EXPECTED_SIZES["CF_RULE"] drift guard in
packages/python/tests/test_surface.py from 88 to 168
Testing:
- make python-test: 52/52 pass, including
test_cf_add_get_evaluate_clear and test_struct_sizes
- make python-wheel followed by installing the built wheel into a
fresh venv and running the test suite against it (the same path
release.yml's smoke test step runs): 52/52 pass
- Native ctest -LE "SLOW|LOAD|BENCH": 14929/14929 pass, confirming no
native regression from this Python-only change1 parent 56b23b8 commit 2450c75
2 files changed
Lines changed: 30 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
40 | 48 | | |
41 | 49 | | |
42 | 50 | | |
| |||
77 | 85 | | |
78 | 86 | | |
79 | 87 | | |
80 | | - | |
81 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
82 | 91 | | |
83 | 92 | | |
84 | 93 | | |
85 | 94 | | |
86 | | - | |
| 95 | + | |
87 | 96 | | |
88 | 97 | | |
89 | 98 | | |
| |||
248 | 257 | | |
249 | 258 | | |
250 | 259 | | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
251 | 277 | | |
252 | 278 | | |
253 | 279 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
0 commit comments