jkomoros / boardgame

An in-progress framework in golang to easily build boardgame Progressive Web Apps
Apache License 2.0
31 stars 4 forks source link

Clean up implementation of codegen pkg #746

Open jkomoros opened 4 years ago

jkomoros commented 4 years ago

If you run boardgame-util codegen in a package that doesn't have any reader structs decorated with //boardgame-util:codegen, then it outputs auto_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

jkomoros commented 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

jkomoros commented 4 years ago
jkomoros commented 4 years ago

348c901fc1e5dd59c91dfb7ed1e53f62e7e4ae4d and 781ab3670d2fafa116811f045d139e20b6dbb938 are also part of this but were erroneously labeled as being part of #764

806e189f2321a7e523145b8ae00d8fd9853ab61f should have said issue 746