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:
- Source rewriter — lower
[[h5::xxx(...)]] → [[clang::annotate("h5::xxx", ...)]]
- Attribute reader — extract string/int args from
AnnotateAttr
- Consumer extension —
H5TemplateCallback reads per-field attributes
- Producer extension —
H5Producer 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
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
Background
h5cpp issue #258 added library-side scatter/gather dispatch infrastructure:
h5::has_scatter<T>traitH5CPP_REGISTER_SCATTER(T)macroh5::scatter<T>/h5::gather<T>generic templatesh5::detail::write_one_row/read_one_rowhelpersThe 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:
[[h5::xxx(...)]]→[[clang::annotate("h5::xxx", ...)]]AnnotateAttrH5TemplateCallbackreads per-field attributesH5Produceremits code respecting attributesAttributes to Support (Tier 1)
[[h5::name("on_disk_name")]]H5Tinsertfield name[[h5::ignore]]H5Tinsertemitted[[h5::chunk(N, M, ...)]][[h5::compress(gzip, 6)]]Scatter/Gather Emission
For tier-2 types (structs with
std::vector/std::stringfields):h5::generated::T_::row_tmirror structh5::generated::T_::compound_type()withH5Tvlen_creatememberstemplate<> h5::ds_t h5::scatter<T>(...)specializationtemplate<> void h5::gather<T>(...)specializationH5CPP_REGISTER_SCATTER(T);Acceptance Criteria
h5_attr_translator.hpprewrites clean[[h5::...]]syntax toclang::annotateh5_attr_reader.hppextracts args from annotate attrs (reusable from pb)consumer.hppskips[[h5::ignore]]fields and reads[[h5::name]]overridesproducer_h5.hppemits renamed fields and respects[[h5::chunk]]/[[h5::compress]][[h5::name]]and[[h5::ignore]]pass against golden filesscatter<T>/gather<T>codeDependencies
Notes
h5::name,h5::ignore,h5::doc, etc. mirrorpb::name,pb::ignore, etc.[[=h5::name{...}]]under P3394