Part of #118 (dedx_extra.c migration) · Phase D. Depends on Phase C (#121) landing first.
Problem
The core inverse functions (dedx_get_inverse_csda, dedx_get_inverse_stp in dedx_tools.h) require a caller-managed dedx_workspace* + dedx_config* (allocate → set ion_a → dedx_load_config → call → free). That lifecycle cannot be driven safely from JavaScript/WASM, so dedx_web wraps it in wasm/dedx_extra.c as "flat" one-call functions.
libdedx already ships this convenience style in dedx_wrappers.h (dedx_get_simple_stp_for_program, dedx_get_stp_table, dedx_get_csda_range_table, …). The flat inverse wrappers belong right next to them.
Proposed change
Add to include/dedx_wrappers.h (handling workspace/config lifecycle internally):
double dedx_get_inverse_csda_simple(int program, int ion, int target,
double range, int *err);
double dedx_get_inverse_stp_simple(int program, int ion, int target,
double stp, int side, int *err);
double dedx_get_bragg_peak_stp_simple(int program, int ion, int target, int *err);
(Names to match the existing *_simple_* convention — final call by a maintainer. dedx_web currently names them *_flat.)
These set cfg.ion_a from the nucleon-number accessor (Phase A, #119) before dedx_load_config, which is the subtle bit the inverse functions require.
Acceptance criteria
Reference
dedx_web wasm/dedx_extra.c (lines ~221–455).
Filed via Claude Code as part of the dedx_extra.c → libdedx migration plan.
Part of #118 (dedx_extra.c migration) · Phase D. Depends on Phase C (#121) landing first.
Problem
The core inverse functions (
dedx_get_inverse_csda,dedx_get_inverse_stpindedx_tools.h) require a caller-manageddedx_workspace*+dedx_config*(allocate → setion_a→dedx_load_config→ call → free). That lifecycle cannot be driven safely from JavaScript/WASM, so dedx_web wraps it inwasm/dedx_extra.cas "flat" one-call functions.libdedx already ships this convenience style in
dedx_wrappers.h(dedx_get_simple_stp_for_program,dedx_get_stp_table,dedx_get_csda_range_table, …). The flat inverse wrappers belong right next to them.Proposed change
Add to
include/dedx_wrappers.h(handling workspace/config lifecycle internally):(Names to match the existing
*_simple_*convention — final call by a maintainer. dedx_web currently names them*_flat.)These set
cfg.ion_afrom the nucleon-number accessor (Phase A, #119) beforededx_load_config, which is the subtle bit the inverse functions require.Acceptance criteria
dedx_wrappers.h; each wrapper is self-contained and re-entrant (fresh workspace per call — note for thread-safety make library thread-safe #86).dedx_get_inverse_csda_flat/dedx_get_inverse_stp_flat/dedx_get_bragg_peak_stpfromwasm/dedx_extra.cand updateswasm/contract-manifest.json+docs/06-wasm-api-contract.md.Reference
dedx_web
wasm/dedx_extra.c(lines ~221–455).Filed via Claude Code as part of the
dedx_extra.c→ libdedx migration plan.