Swift: use structured generated C++ classes in DeclVisitor#9230
Conversation
17e8be0 to
e84cef8
Compare
314dd2e to
685ffc9
Compare
9d03e87 to
b0668ee
Compare
e84cef8 to
f985003
Compare
000aaf0 to
1ab095a
Compare
DeclVisitor
|
I made the PR a bit smaller than before and added some comments to the new functions. With respect to the previous version of this PR, I undid the I also moved |
1ab095a to
43888e7
Compare
sashabu
left a comment
There was a problem hiding this comment.
I've reviewed the "interesting" parts of this PR, but:
- I haven't done a thorough review of
DeclVisitor.hsince it looks fairly mechanical and - I'm not familiar with Mustache syntax, so I only commented on what I think the resulting C++ will look like
since Alex is the main reviewer. Let me know if you'd like a more thorough review from me.
43888e7 to
c65462e
Compare
sashabu
left a comment
There was a problem hiding this comment.
LGTM with the same caveats that:
- I haven't done a thorough review of DeclVisitor.h since it looks fairly mechanical and
- I'm not familiar with Mustache syntax, so I only commented on what I think the resulting C++ will look like
That class was meant to allow aggregate initialization of generated
C++ entries having the label `id` as first argument.
As aggregate initialization turned out to be undesirable (names of
fields are not explicit, and `{}` must be inserted for empty
superclasses), this commit removes it and disallows aggregate
initialization altogether by defining empty constructors for generated
classes.
Translation now takes const references to swift entities and return trap entries (instead of taking apointer as an out parameter).
This disallows completely calling the disabled function (which could be done by explicitly providing `void` otherwise).
68716ee to
6e44a12
Compare
While we need universal references to catch different value categories, we don't need perfect forwarding as `fetchLabel` does not behave differently on lvalue and rvalues.
|
@AlexDenisov I've merged your deduplication branch into this and selected it as a target. Once we merge that, I can rebase this and put it back to review. |
This PR introduces using structured generated C++ classes in
DeclVisitor.The coding style moves to translation methods taking in a swift entity and filling a trap class instance, a bit in the style of gRPC method implementations. Shortcuts are provided to fill optional and repeated properties (
fetchOptionalLabelandfetchRepeatedLabels). No explicit mention of trap entries is needed any more, but they could still be used alongside this higher-level interface.Also, the
Bindingtemplate class has been removed and aggregate initialization of generated C++ classes disallowed.Bindingwas meant to allow aggregate initialization of generated C++ entries having the labelidas first argument, before fields from superclasses.As aggregate initialization turned out to be undesirable (names of fields are not explicit, and
{}must be inserted for emptysuperclasses),
Bindingis removed it and aggregate initialization are disallowed by defining empty constructors for generatedclasses.