Skip to content

Expose nucleon number, atom mass, density and is-gas in the public header #119

@grzanka

Description

@grzanka

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions