Skip to content

Add public dedx_get_material_display_name() and make C the single source of truth for display names #120

@grzanka

Description

@grzanka

Part of #118 (dedx_extra.c migration) · Phase B.

Problem

dedx_get_material_name() returns raw ALL-CAPS identifiers with no spacing (e.g. WATER, CARBONDIOXIDE, TISSUE_EQUIVALENTGAS_METHANEBASED). Human-readable display names — with critical disambiguation such as Water (liquid) vs Water Vapor — currently live in two hand-maintained copies that will inevitably drift:

  • C: dedx_get_material_friendly_name() in wasm/dedx_extra.c (151 overrides, currently static and not even exported). Its own comment says "Intended for future inclusion in libdedx as a public API function."
  • TypeScript: MATERIAL_NAME_OVERRIDES in src/lib/config/material-names.ts (151 entries).

Proposed change

Promote the override table into libdedx as a public function:

/** Human-readable display name for a material, with disambiguation
 *  (e.g. "Water (liquid)" vs "Water Vapor"). Falls back to the raw
 *  dedx_get_material_name() for unmapped ids. */
const char *dedx_get_material_display_name(int material);

Make this C table the single source of truth and remove the duplicate from dedx_web (either expose it through the WASM build, or generate the TS table from it at build time with a drift-guard check).

Open decision

Does C return fully-formatted names for all materials, or C-overrides + a documented title-case fallback that the binding still applies for un-overridden elemental names? (See §6 of the migration plan.)

Acceptance criteria

  • dedx_get_material_display_name() declared in include/dedx.h, defined with the override table.
  • Bounds-checked; safe fallback to dedx_get_material_name().
  • Test covering at least the Water-liquid/vapor disambiguation and a run-on compound.
  • dedx_web removes its duplicate table and adds a drift guard.

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