Add refactored/revamped JSON schema codegen#307
Add refactored/revamped JSON schema codegen#307krupkad wants to merge 5 commits intogltf-schema-prettierfrom
Conversation
|
Thanks again for your contribution @krupkad! No one has commented on this pull request in 30 days. Maintainers, can you review, merge or close to keep things tidy? I'm going to re-bump this in 30 days. If you'd like me to stop, just comment with |
|
I'd like to take over this branch and help move it along so that we no longer have two code generators that are slowly getting more and more out of sync with each other. My plan is this:
I plan on starting on this ASAP so please post any thoughts if this is not the right direction. |
|
Some notes after diving a little bit deeper today
|
|
@krupkad let me know if I'm missing anything in my comments above. |
|
There are some deeply technical questions in there, and I haven't looked at the details e.g. of the extension mechanisms, so cannot say much about that. But ... apologies for the apparent bike-shedding here:
I can see the point of adding convenience functions in On the other hand, I see the rationale of giving the extending classes the "simple, straightforward" names, because these are the ones that are actually used by clients. So that's not a really strong opinion, but I think it would be nice if one could state a rule like "Entity X is found in |
|
In no particular order:
|
It's ok. I still have a slight preference for template literals, but I won't complain too much. The way I see it:
But if we are sending the generated code through clang-format, the indentation handling is mostly irrelevant. And having spent a lot of time with React, which also doesn't have
Yes agreed!
I don't think that can work. The problem is that the But in general, we should try to avoid using this
Hmm most of this doesn't make sense to me, not sure what I'm missing. Entity X is always found in X.h. There's just a generated XSpec.h under the hood in same cases, too, but users don't need to worry about those. Adding convenience functions to other classes requires us to tweak the generator config to create a XSpec class (set
I think it's not really used anymore. Instead, the assocation between extensions and the objects they extend is hard-coded in the GltfReader constructor where it registers extensions on particular types. If we can generate this code from the extension JSON Schema (e.g. based on the extension file name as you suggested), that would be excellent, but it probably needs work on the spec side. In the absence of that, defining the attachment manually in code seems just as good as definining it manually in a JSON config file.
I don't think this will work once we're generating some of the types a
👍
Yeah, it's going to take some work. I don't know what the answer is here.
I'm not sure I totally understand the issue here.
The extension names in the existing code are pretty cumbersome. Maybe we should normalize them by prefixing with Daniel's idea of using namespaces is an interesting one! Put all the extensions in CesiumGltf::Extensions and then remove that
Of these, |
It still would have to check whether there are
The second part is IMHO the crucial one here. And if these objects are not extended with data, then I don't see a problem. The options are then, roughly:
(I mean, there currently is a convenience function in Regarding the cases where this is not possible (namely, |
db235b2 to
6cde110
Compare
|
Thanks for the insights everyone. I'll still be referring back to these comments but now that #361 is merged this PR can be closed. |
This is a fairly revamped JSON schema / C++ codegen, which I used to generate the 3D Tiles struts and writers in #306.
Main functional differences:
enum: ["value1", "value2"], which is used in 3D Tiles but not glTF and not handled by the current codegen)Reader/struct generation:
-Specandfinalin the struct output - felt somewhat "extra" and not really neededWriter generation:
writeJsonin an anonymous namespace in cpp filesTilesetWriter) with a single static methodwrite, which just callswriteJsonwriteJsonimplementations for primitive types (double, string, integer, bool), composites (string->X dictionary, array), andoptionalCode structure:
resolveProperty.jsonto utilize JS clases to better organize the handlers for the various JSON schema typesgenerate.jsonto use handlebars.js and external templates (see the files intemplates/) do the actual codegen (vs. embedded format strings in the JS itself)