Skip to content
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

Alternatives to ProtocolObject #460

Closed
wants to merge 1 commit into from
Closed

Conversation

madsmtm
Copy link
Owner

@madsmtm madsmtm commented Jun 15, 2023

I suspect it may be possible for us to basically never need to use ProtocolObject, but instead rely on the compiler to do the work of figuring out which traits are valid for which objects.

In this PR I've experimented with CoercedUnsized for Id, to show that it can indeed work through that. If we also changed message sending such that &dyn NSObjectProtocol translates to NonNull<AnyObject>, then using protocol objects would look very, very similar to normal Rust code (methods take &dyn MyProtocol and end up returning Id<dyn MyProtocol>).

One worry is that the vtable may be included in the final binary, that would have to be thoroughly tested beforehand.

@madsmtm madsmtm added enhancement New feature or request question Further information is requested A-objc2 Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` crates labels Jun 15, 2023
@madsmtm madsmtm closed this Dec 30, 2024
@madsmtm madsmtm deleted the phase-out-protocolobject branch December 30, 2024 05:44
@madsmtm
Copy link
Owner Author

madsmtm commented Dec 30, 2024

I've experimented a bit with this in bb1ae6f, and decided to track the rest of this PR in #686.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-objc2 Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` crates enhancement New feature or request question Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant