-
Notifications
You must be signed in to change notification settings - Fork 67
[ffigen] ObjC id<Foo>
-> Dart Foo
#1959
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PR HealthBreaking changes ✔️
API leaks ✔️The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
License Headers ✔️
All source files should start with a license header. Unrelated files missing license headers
|
id<Foo>
-> Dart Foo
id<Foo>
-> Dart Foo
HosseinYousefi
approved these changes
Feb 3, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is the second part of #1462. API methods that accept
id<Foo>
are now code-genned as takingFoo
instead ofObjCObjectBase
. The protocol'simplement
method also returns that protocol instead ofObjCObjectBase
.There's a big caveat with this solution. I couldn't think of a way of capturing the semantics of
id<Foo, Bar>
, so I'm treating it as if it's justid<Foo>
. This means that there are still cases where you can pass the wrong type of object to these methods. But I think these cases are pretty rare, and the failure case is just that the compiler is a bit too permissive, so it's probably not a big deal.Details
ObjCObjectPointerWithProtocols
.id
into eitherObjCObjectPointer
orObjCObjectPointerWithProtocols
depending on whether it has any conforming protocols.castFrom
andcastFromPointer
methods that interfaces have, as an escape hatch, and to support more advanced use cases that useObjCProtocolBuilder
to implement multiple methods.interface class
instead ofabstract interface class
.conformsTo
method, analogous to interface'sisInstance
method. This method doesn't work for Dart constructed protocols, but I can add support for that if a user needs it.Foo
fromid<Foo>
, the AST has a weird shape. Instead of the AST looking like (decl -> methods/etc), it looks like (stubDecl --superProto-> decl -> methods/etc). So I had to add some logic in the protocol parser to detect this case and parse the true decl instead.Fixes #1462