tigregalis / wittier

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Customisable codegen / disambiguation

tigregalis opened this issue · comments

In order from most desired and hardest, to least desired and easiest:

  1. Generate all the things, if possible to be maximally flexible, within the given constraints of wasm/wit. This may require being highly opinionated.

  2. 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)

  3. A config file for hooks and disambiguation

  4. A combination of 2 and 3: the first generation is interactive, which gives you a config file, which you can reuse for future generations.

  5. 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)

  6. 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.