wit-bindgen
wit-bindgen copied to clipboard
Improve identifier generation across languages
Right now generating identifiers is pretty ad-hoc across all the language bindings. I created a Ns type for use in the C bindings generator but even then it's only lightly used and not to its fullest extent. I think that identifier generation should be improved across all languages and centralized into one location to make it easier to work with:
- All identifiers generated should go through some sort of "namespace" (the
Nstype). Every, single, identifier. - Languages can configure
Nsto do the right thing, but otherwise it'd have methods for snake/camel/mixed case verisons of identifiers. - All intrinsics used by language bindings should be "temporary" symbols that can be renamed to give prioritization to user-defined symbols via witx.
- Types like
Nscould automatically handle language keywords and language identifier rules (e.g. can't start an identifier with a digit)
In theory this should just be a refactoring, but I think it would help improve code generation by ensuring that there aren't weird bugs in the generated code where a witx symbol accidentally overlaps with some sort of intrinsic or something like that.