Skip to content

refactor - #18

Merged
chenyan2002 merged 2 commits into
mainfrom
refactor
Oct 4, 2026
Merged

chenyan2002 merged 2 commits into
mainfrom
refactor

Conversation

@chenyan2002

@chenyan2002 chenyan2002 commented Oct 4, 2026 •

Copy link
Copy Markdown
Owner
  • wrapped naming in one place. The "wrapped-" / "wrapped_" strings that were copied around now live in a few small helpers in src/util.rs. codegen/mod.rs, codegen/record.rs, traits/proxy.rs and util.rs now use those helpers instead of hand-editing prefixes.
  • generate_wrapped_wits split in two. It used to do two jobs. Now one function builds conversion.wit (all modes) and another builds the wrapped-* packages (Record mode only). Both are called from generate_component and hand their files back like everything else, instead of writing to disk themselves.
  • No second WIT parse. They reuse the WIT that instrument.rs already parsed instead of reading the directory again.
  • Less repeated code in ast.rs:
    • one helper for the recorder/debug/dialog imports (was written twice);
    • one helper to list interface names (replaces six copies of the same loop);
    • small helpers for the link lines in generate_wac;
    • load_imports and load_exports share one function for reading a component's imports.
  • Clearer bookkeeping. LinkInfo and its unused fields are replaced by four plainly named maps/sets.
  • Errors instead of panics. An unsupported world item or a non-component input now returns an error instead of hitting todo!() / panic!(). That's the only intended behaviour change.
  • remove magic42 in get-mock- conversion function by storing the type alias in the bindgen code, and extract the last segment in the full path.

@chenyan2002
chenyan2002 merged commit 6012d07 into main Oct 4, 2026
2 checks passed
@chenyan2002
chenyan2002 deleted the refactor branch October 4, 2026 20:13
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