-
Notifications
You must be signed in to change notification settings - Fork 45
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
Allow multiple colons in selectors #336
Conversation
26eb66b
to
983633e
Compare
983633e
to
9cc6288
Compare
Thanks for starting on this. I was taking a look at the changes and although it seems like it should fix some of the issues with methods that currently need to be skipped there may still be some problems that remain. When I was trying this PR locally, I still ran into problems with methods that get translated as duplicate names. For instance, we have situations like this: extern_methods!(
#[cfg(feature = "WebKit_WebView")]
unsafe impl WebView {
#[method(goForward)]
pub unsafe fn goForward(&self) -> bool;
}
);
extern_methods!(
/// WebIBActions
#[cfg(feature = "WebKit_WebView")]
unsafe impl WebView {
#[method(goForward:)]
pub unsafe fn goForward(&self, sender: Option<&Object>);
}
); I also notice that in the examples that now translate in the PR, all of the trailing unsafe impl CAMediaTimingFunction {
#[method_id(@__retain_semantics Other functionWithControlPoints::::)]
pub unsafe fn functionWithControlPoints(
c1x: c_float,
c1y: c_float,
c2x: c_float,
c2y: c_float,
) -> Id<Self, Shared>;
} So it seems we may run into a general issue with disambiguation, say if we have a selector like I guess the problem with just always naively translating Maybe an alternative approach that would resolve these potential issues would be to adopt a strategy like the following:
(2) should not be too difficult, but one potential downside is that it could lead to an additional source of breakage with regard to #338 if a new ambiguating method gets added in an updated SDK. Another possibility might be to allow specifying a particular renaming for a given selector directly in the translation config file and then just manually patching up these cases. I suppose the ambiguous cases are probably rare enough that that would suffice and would maybe lead to nicer names anyway (at the potential of some slight confusion, at least until or unless the API docs are linked into the generated output). Any thoughts on whether this might work or if there is a better way to handle these issues in general? |
That's a great idea, we should definitely do that!
We could use some kind of ambiguity detection anyhow for duplicate class & instance methods. I would guess it would be easiest as a post-processing step in
Good point, though probably quite unlikely (and if it's the case, we can fix it manually just like the other breakage there).
I've been considering this anyhow in #330, and will also be necessary when we start doing #284. Really, I'm unsure of how common it is that method names are duplicated, which is kind of required knowledge to figure out which fix is the better solution? Perhaps one could run a test script against all frameworks in |
We could probably also use |
Okay, I will give it a shot. I did briefly try to modify the translation of the selectors earlier, specifically removing the trimming of trailing colons here but after doing that and running the translator again it almost immediately errored out with some problem about argument analysis IIRC. But maybe a post processing step in |
Perhaps because after the function name changed, So yeah, I think a post-process step will avoid this. |
Should help cutting down on the amount of work #327 and futures has to do. Tagging @silvanshade.