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

Record metadata for a struct implementing a trait. #2204

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mhammond
Copy link
Member

@mhammond mhammond commented Aug 6, 2024

#[uniffi::export]
impl MyTrait for MyObject { ... }

Currently works by ignoring MyTrait. This adds new metadata
to record it, allowing foreign bindings to implement things like
inheritance

Includes Python, Kotlin and Swift generating these sub-classes.
There's some undesirable re-wrapping when traits from these
objects gets passed back and forward, but seems to work surprisingly well.

Fixes #2196.

@mhammond mhammond requested a review from gruberb August 6, 2024 13:42
@mhammond mhammond requested a review from a team as a code owner August 6, 2024 13:42
@mhammond mhammond force-pushed the push-yolpttzuvznp branch 3 times, most recently from 5411e96 to fa42fd1 Compare September 4, 2024 02:02
@mhammond
Copy link
Member Author

mhammond commented Sep 4, 2024

Bindings all turned out to be fairly easy - which in some ways is "bad" because it highlights an inefficiency here, but good because it seems fine and useful.

```
#[uniffi::export]
impl MyTrait for MyObject { ... }
```

Currently works by ignoring `MyTrait`. This adds new metadata
to record it, allowing foreign bindings to implement things like
inheritance

Includes Python, Kotlin and Swift generating these sub-classes.
There's some undesirable re-wrapping when traits from these
objects gets passed back and forward, but seems to work surprisingly well.

Fixes mozilla#2196.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tell the bindings about traits implemented by objects.
1 participant