Skip to content

refactor(elements)!: one SimpleDecoder replaces the 67 decoder types 15 copies of simple_decoder! generated - #894

Merged
DrunkOnJava merged 3 commits into
mainfrom
refactor/simple-decoder
Oct 23, 2026
Merged

DrunkOnJava merged 3 commits into
mainfrom
refactor/simple-decoder

Conversation

@DrunkOnJava

Copy link
Copy Markdown
Owner

Summary

macro_rules! simple_decoder was defined 15 times, byte-for-byte identical, once per element file, and each of its 67 expansions was a public unit struct plus an ElementDecoder impl. One documented type, elements::SimpleDecoder { class_name }, now does the same job, and the registry lists SimpleDecoder::new("<class>") for each of those 67 classes. No macro remains.

Motivation

Found by the 2026-10-23 style audit (Google Rust style guide, "Macros": prefer types to macros; and the 67 generated structs had no docs, a large share of the crate's undocumented public items). The element modules are stable API under #873, so this belongs before 1.0.

Changes

  • src/elements/simple_decoder.rs (new): SimpleDecoder, with the macro's exact decode / decode_with_limits behaviour (wrong-schema refusal, decode_instance_with_limits at offset 0).
  • src/elements/mod.rs: pub use simple_decoder::SimpleDecoder;; the 67 registry entries become Box::new(SimpleDecoder::new("<class>")), same classes, same order. Module docs say how to register a simple class.
  • 15 element files: the macro and its invocations removed, and the imports only it used.
  • src/elements/mep.rs: the coverage table names the registration.
  • templates/element-decoder/: registers through SimpleDecoder; no longer generates unit tests (banned in this repository), and the README's step 3 asks for a real-file check instead.
  • CHANGELOG.md: a breaking Changed entry.

Testing

No unit tests (banned). The decode path is identical, so the evidence is CI plus Measure:

  • CI (clippy, real-file targets including iter_elements_typed)
  • Measure against main: every export unchanged (link in a comment)

Audit-honesty checklist

  • Docs match the code after this PR
  • No emojis, private paths or internal jargon

Legal and contribution hygiene

  • Apache-2.0; no Autodesk proprietary source; no fixtures

Breaking changes

The 67 unit types (mep::DuctDecoder, generic::MassDecoder, ...) are gone; SimpleDecoder::new("Duct") decodes what mep::DuctDecoder did. The wrong-schema error text changes to <class> decoder received wrong schema: ....

Screenshots or output samples

N/A: no output change.

@DrunkOnJava
DrunkOnJava marked this pull request as ready for review October 23, 2026 11:50
@DrunkOnJava

Copy link
Copy Markdown
Owner Author

Measure against main (run 39947761202, head 6e623af): on all six reference models ifc.sha256 and every scorer output are identical to main's; only timing lines differ. CI is green on the same commit. It needs a branch update after #890 lands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6e623af4e5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/elements/mod.rs Resolved
@DrunkOnJava
DrunkOnJava merged commit 9abe6a6 into main Oct 23, 2026
27 checks passed
@DrunkOnJava
DrunkOnJava deleted the refactor/simple-decoder branch October 23, 2026 12:13
Repository owner deleted a comment from chatgpt-codex-connector Bot Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant