Customisable codegen / disambiguation
tigregalis opened this issue · comments
In order from most desired and hardest, to least desired and easiest:
-
Generate all the things, if possible to be maximally flexible, within the given constraints of wasm/wit. This may require being highly opinionated.
-
An interactive command line for "hooking into" the generator and for disambiguation (strategies or decisions as to how a Rust item should be expressed in wit)
-
A config file for hooks and disambiguation
-
A combination of 2 and 3: the first generation is interactive, which gives you a config file, which you can reuse for future generations.
-
Annotations in Rust / Rustdoc for the actual library (not sure if built in feature or have to fake it with a trait and associated constant, plus proc-macro attribute)
-
Generate only a baseline, then developer takes over
Examples of disambiguation include:
-
whether something should be expressed as a record/enum/variant/bitflag/primitive or whether it should be expressed as a resource
-
whether something should be owned or borrowed
-
whether to express constants as enums or as functions that return a static value
-
what types to monomorphise generics for (or perhaps generate as variants)
There may be certain heuristics like, if it contains a private field (cannot be constructed by the client directly, but only via a function) then it is a resource.