Open jkomoros opened 4 years ago
Actually, codegen needs more cleanup anyway, making this issue mor general.
Importing from #741: codegen.ProcessReaders is a ball of spaghetti. Create an internal struct that is codeGenStruct for each struct to output code for that encapsulates all of the information necessary to append generated code to output, which will include type names as well as the struct name, whether it has a FinishStateSetUp, which of read, readset, and readsetconfigurer to output, and which behaviors need to be connected, etc
auto_reader.go
with no substantive code is emittedgo/types
to process type info without using the marcgrol package (although that doesn't have doclines does it? ... that's OK; just have a top-line thing to process a single package to extract the struct names that have the magic comment, and then hand off to a normal parsing thing with the map of structs to export and do all of that with the go.Types package)348c901fc1e5dd59c91dfb7ed1e53f62e7e4ae4d and 781ab3670d2fafa116811f045d139e20b6dbb938 are also part of this but were erroneously labeled as being part of #764
806e189f2321a7e523145b8ae00d8fd9853ab61f should have said issue 746
If you run
boardgame-util codegen
in a package that doesn't have any reader structs decorated with//boardgame-util:codegen
, then it outputsauto_reader.go
, with imports but no code, which will then cause the package to not compile since it has unused imports.This is rarely run into in practice because you have to invoke
boardgame-util codegen
via//go:generate boardgame-util codegen
, and if you included that then you almost certainly have at least one struct that needs a reader.Noticed while working on #741