Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[swift2objc] Filtering Support #1730
base: main
Are you sure you want to change the base?
[swift2objc] Filtering Support #1730
Changes from all commits
0c6ae4f
6b42b1c
d9a926d
2af7024
34d05ed
93c7879
dbe4ba4
38bbbbc
19e1504
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODOs should link to a bug. If there isn't one, file one first, then link to the bug like
TODO(https://github.com/dart-lang/native/issues/...): Type restrictions...
Same below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't have to re-parse these types from strings. We did all the parsing already, and now have a nice clean AST to work with. In this case you can just check if the
type
is aDeclaredType
, and get itsid
ordeclaration
or whatever. Also need to handle theOptionalType
case.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This algorithm is pretty hard to follow. A simpler approach would be to give
DependencyVisitor
a memberSet
that it outputs all the dependencies into.generateDependencies
would just construct aDependencyVisitor
, then iterate over every element ofdecls
and calldependencyVisitor.visitDeclaration
, then return theSet
thatdependencyVisitor
constructed.DependencyVisitor.visitDeclaration
would just DFS from the given element to any child element not in thatSet
. This would also mean you don't have to pass around thecontext
variable through all thosevisit
methods inDependencyVisitor
, because thecontext
would be replaced by this memberSet
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for recursiveness is because of at the moment, the algorithm generates bindings for all parts of all dependencies of filtered types, and since these parts (e.g methods and properties) may also require types as well, those are generated as well recursively.
What can be done, is to pass the declarations to
DependencyVisitor
, allow it to perform the recursive visiting, and then return the output.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, all that recursion should happen inside the visitor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Names aren't unique (eg two nested types, nested in different parent types, can have the same name). Use the declaration
id
instead.Better yet, why not just have the dependency visitor construct a
Set<Declaration>
directly, rather than constructing aSet<String>
and then looking up the declaration from the string?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the types do not reference declarations directly (like function parameters, variable types), which therefore means that declarations need to be looked up eventually.
The lookup is done afterwards to prevent multiple lookups and just have a single lookup per visitation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't ever need to look up types by name or id, after parsing is complete. The AST already has references to the declarations. Check if the
ReferredType
is aDeclaredType
.