Part of #118 (dedx_extra.c migration) · Phase A.
Problem
dedx_web re-exports four one-line accessors from wasm/dedx_extra.c because the underlying functions, while already implemented in libdedx, have no public header declaration:
| dedx_web shim |
Already-existing libdedx implementation |
dedx_get_ion_nucleon_number(ion) |
dedx_internal_get_nucleon() — src/dedx_periodic_table.c |
dedx_get_ion_atom_mass(ion) |
dedx_internal_get_atom_mass() — src/dedx_periodic_table.c |
dedx_get_density(material, *err) |
dedx_internal_read_density() — src/dedx_data_access.c |
dedx_target_is_gas(target) |
dedx_internal_target_is_gas() — src/dedx_data_access.c |
Every frontend/binding that needs a material density or an ion's nucleon number currently has to add its own shim.
Proposed change
Add public, bounds-checked declarations in include/dedx.h (thin definitions in src/dedx.c or the owning .c), e.g.:
int dedx_get_nucleon_number(int ion, int *err); /* A (nucleon count) */
float dedx_get_atom_mass(int ion, int *err); /* atomic mass */
float dedx_get_density(int material, int *err); /* g/cm³ */
int dedx_is_gas(int target, int *err); /* 1 = gas, 0 = condensed */
Naming to match existing dedx_get_* conventions (final names a maintainer call).
Acceptance criteria
Downstream unblocks
dedx_web issues #175 (display selected-material density) and #176 (custom material density).
Filed via Claude Code as part of the dedx_extra.c → libdedx migration plan.
Part of #118 (dedx_extra.c migration) · Phase A.
Problem
dedx_web re-exports four one-line accessors from
wasm/dedx_extra.cbecause the underlying functions, while already implemented in libdedx, have no public header declaration:dedx_get_ion_nucleon_number(ion)dedx_internal_get_nucleon()—src/dedx_periodic_table.cdedx_get_ion_atom_mass(ion)dedx_internal_get_atom_mass()—src/dedx_periodic_table.cdedx_get_density(material, *err)dedx_internal_read_density()—src/dedx_data_access.cdedx_target_is_gas(target)dedx_internal_target_is_gas()—src/dedx_data_access.cEvery frontend/binding that needs a material density or an ion's nucleon number currently has to add its own shim.
Proposed change
Add public, bounds-checked declarations in
include/dedx.h(thin definitions insrc/dedx.cor the owning.c), e.g.:Naming to match existing
dedx_get_*conventions (final names a maintainer call).Acceptance criteria
include/dedx.hwith Doxygen comments (units: density ing/cm³).ion/materialreturns a safe sentinel and sets*err(ties into the bounds-check item in [Tracking] libdedx health review — correctness, API hygiene, docs & ecosystem (web + Python) #108).tests/and a usage line in an example.wasm/dedx_extra.cand call these directly.Downstream unblocks
dedx_web issues #175 (display selected-material density) and #176 (custom material density).
Filed via Claude Code as part of the
dedx_extra.c→ libdedx migration plan.