Closed Sp00ph closed 2 years ago
Using paste we might also be able to merge the struct definition and the getter / setter definitions, i might look into it later.
Actually nevermind, i forgot the struct definition is just a simple one liner, probably not worth it to make a more complicated macro then.
I don't think that using a dependency here is a good trade. The amount of extra typing that I end up doing to have the "with" methods is nearly none. Using a multi-line select in VSCode I just pick out the getter names, then it's something like: left arrow, , with_
, then paste the names in, and it's all done.
What's the problem with a small build time dependency like paste? I mean I kinda get your point, but the paste compile time is completely by the time it takes to compile core anyways. Also this way there's no potential for naming inconsistency by way of typos, though in your case specifically using copy+paste obviously also makes that a non-issue.
hm, I hadn't considered that it can build in parallel with core
. I suppose it's fine then.
I'll merge it for now and maybe later I'll double check that rebuild times aren't notably affected (probably they aren't).
I think I misunderstood earlier and thought that this was going to be a dev-dependency
rather than a normal dependency
. I'd strongly perfer that 100% of the gba
build tree be Zlib compatible if possible. That puts me back on the fence, but i'll keep it for now.
Oh right, I didn't think about licenses, sorry about that.
I'm probably being a little too picky, and it is nicer during the initial development to only write each thing once.
I'll probably finish all the main MMIO structs like this and then do a pass of the "multi-line copy and paste" thing once at the end.
The different macros used to define fields all had to specify both the getter name and the with-name, which seemed to me like needless repetition, as the with-name was always just
with_$name
, so with the use of thepaste
crate I've made it so that you can only give it the field name and by default it automatically useswith_$name
as the with-method name. I haven't removed the old macro rule, so if you ever want to use a different with-name for some reason, that's still possible.