Add non scalar default support to BFBS files
This PR adds in an extra field to the reflection.fbs that holds string representations of non scalar defaults -- vectors and strings, specifically.
This isn't the 'best' way to accomplish this, but I think its the most pragmatic given how prolific the Value struct is in the code base.
Accepting suggestions for better names!
@dbaileychess and @aardappel interested to hear your collective take on this one! I realized this was missing while working on the wireshark generator.
This PR has formatting and other changes that appear not directly related that make it hard to review.
Why is the new bool in Value needed? Doesn't the Type already tell you if it is scalar or not?
This is getting at the inelegance of the design -- much of the code relies on the constant string being default constructed as "0". Pair that with std::string not being able to differentiate between empty and unset and you end up either needing to do a large refactor, or pull some shenanigans like this.
I tried to just default construct constant and set it to 0 if a scalar type, but then I couldn't tell the difference between "user set default to "" and no default. Which is probably okay? But with all of the modifications needed to go that route it seemed wrong. I can try that again if the bfbs doesn't need to tell the difference between set to empty and unset, maybe I tried too many things at once.
in reading up on the non scalar defaults more (#6053), it does seem that the bfbs would need to differentiate between being provided a default ( = "") and not being provided one (nullptr) -- std::string doesn't have a mechanism to differentiate this, so I'm left with
- adding a boolean (implemented here)
- wrapping the
constantmember in some sort of std::optional-esque thing (which I did try, it got messy real fast) - injecting and removing an extra set of
""when a non scalar default is provided (so that.empty()) would mean nothing provided and""""would be equivalent to""which would be set in the bfbs
1 or 3 would work for me, and I can work to remove the auto formatting to make the pr easier to review (vscode format go brrrrrr)
there were only two lines of formatting changes -- the other change is flatc now generates scoped enums instead of unscoped.
@dbaileychess your review here would be helpful