Skip to content

feature, add h5:: attribute support to HDF5 backend #32

@steven-varga

Description

@steven-varga

Background

h5cpp issue #258 added library-side scatter/gather dispatch infrastructure:

  • h5::has_scatter<T> trait
  • H5CPP_REGISTER_SCATTER(T) macro
  • h5::scatter<T> / h5::gather<T> generic templates
  • h5::detail::write_one_row / read_one_row helpers

The h5cpp-compiler HDF5 backend currently has zero C++ attribute support. It emits register_struct<T>() specializations for POD types only, with no handling of [[h5::name(...)]], [[h5::ignore]]", [[h5::chunk(...)]]", etc.

Goal

Add C++ attribute parsing and emission to the h5cpp-compiler HDF5 backend, reusing the proven architecture from pb branches #30/#31:

  1. Source rewriter — lower [[h5::xxx(...)]][[clang::annotate("h5::xxx", ...)]]
  2. Attribute reader — extract string/int args from AnnotateAttr
  3. Consumer extensionH5TemplateCallback reads per-field attributes
  4. Producer extensionH5Producer emits code respecting attributes

Attributes to Support (Tier 1)

Attribute Effect on emitted code
[[h5::name("on_disk_name")]] Override H5Tinsert field name
[[h5::ignore]] Skip field — no H5Tinsert emitted
[[h5::chunk(N, M, ...)]] Dataset chunked layout (required for VLEN)
[[h5::compress(gzip, 6)]] Add filter to DCPL

Scatter/Gather Emission

For tier-2 types (structs with std::vector / std::string fields):

  • Emit h5::generated::T_::row_t mirror struct
  • Emit h5::generated::T_::compound_type() with H5Tvlen_create members
  • Emit template<> h5::ds_t h5::scatter<T>(...) specialization
  • Emit template<> void h5::gather<T>(...) specialization
  • Emit H5CPP_REGISTER_SCATTER(T);

Acceptance Criteria

  • h5_attr_translator.hpp rewrites clean [[h5::...]] syntax to clang::annotate
  • h5_attr_reader.hpp extracts args from annotate attrs (reusable from pb)
  • consumer.hpp skips [[h5::ignore]] fields and reads [[h5::name]] overrides
  • producer_h5.hpp emits renamed fields and respects [[h5::chunk]] / [[h5::compress]]
  • New test fixtures with [[h5::name]] and [[h5::ignore]] pass against golden files
  • Scatter/gather test fixture emits working scatter<T> / gather<T> code

Dependencies

Notes

  • Branch from origin/staging (do not merge pb branches)
  • One vocabulary, two backends: h5::name, h5::ignore, h5::doc, etc. mirror pb::name, pb::ignore, etc.
  • C++26 migration path: same attribute names become [[=h5::name{...}]] under P3394

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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