-
Notifications
You must be signed in to change notification settings - Fork 229
Future of this project and discussion about objc2
#729
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
Comments
I'll keep this relatively short. I've been very happy with switching other crates over to using the They're far more complete and have been free of errors. There are still a lot of API gaps in this repo and binding them by hand is tedious and error prone. There was at least one thing where something in Another thing is that since the coverage of the Apple APIs are more comprehensive. I am porting some code that used Another advantage is that these bindings are closer to the APIs from Apple and more consistently handled. An example of this might be |
One other comment ... I know that this sort of transition will cause some pain. But I do think that:
|
I'm also in favour of transitioning Servo onto the objc2. Maintaining all of these hand-written bindings is a pain. |
I also agree that migrating all of Servo to objc2 seems like the best path forward. While the helpers provided by |
FYI, I recently decided to add a similar function -> method renaming scheme, see madsmtm/objc2#736 (primary motivation was to follow suit with Swift). The renaming isn't done for The issue is somewhat alleviated in We also already emit a But I'd be interested to know if you think it'd be valuable to show the actual name of the method in the documentation? (Alternatively, we could work together with |
@madsmtm These all seem like really reasonable design decisions and seem clearer and more consistent that the previous status quo with crates like |
Hey @waywardmonkeys, @jrmuizel, @mrobinson and @wusyong (and CC @tmandry and @simlay).
Over the past few years, I've been working on replacements for the crates in this repo in the
objc2
project, see #513 and #628 for some previous discussion. To rehash the benefits of theobjc2-*
crates:objc2::rc::Retained
orobjc2_core_foundation::CFRetained
, which will release the object onDrop
. The generator knows about the "create rule" and about opt-outs likeCF_RETURNS_NOT_RETAINED
etc. (so it will do this correctly with a much higher probability than if a human did it).cocoa
andcocoa-foundation
where everything is just an extension trait on theid
pointer.I'm motivated in bringing these benefits to the entirety of the Apple+Rust ecosystem, as I think the soundness, correctness and ergonomics improvements here are quite significant. To that end, I've been slowly migrating major Rust projects, see madsmtm/objc2#174.
A recent milestone is that I've released
objc2-core-foundation v0.3.1
, which I believe now covers everything thatcore-foundation
does! I've also assessed every open issue and pull-request in this repo, and made sure that they're either resolved or tracked in theobjc2
repo, see madsmtm/objc2#719. So at this point, I'd like to start discussing the future of this project, and how we can migrate Servo and other users to theobjc2-*
crates (assuming you agree that's a goal, if not then I'd also like to discuss that!)My ideal scenario would be that the crates in this repo were marked
#![deprecated]
with re-exports of theobjc2-*
variants, both to give users an easier migration path, and because in a way it'd "bless" theobjc2
crates, but I can see other solutions, including any of the following variations:cocoa
andcocoa-foundation
(these are whereobjc2-*
would be the most valuable).#![deprecated]
.A few drawbacks to consider:
objc2-*
crates.objc2-*
crates are a bit less stable thancore-foundation-rs
crates. I do tend to be conservative of breaking changes, and to plan ahead to allow spacing them out as much as possible.objc2-*
crates haven't been audited, so this might hurt them until that happens? CC @ErichDonGubler and @jimblandy maybe?objc2
has fewer maintainers. I'd love to get others on board though, just say so if you want to! Or join the Matrix workspace to start with.Crate status / comparison
Note that I'm not entirely done transitioning things here, see the below table for the current status (which is probably slightly incorrect, there's bound to be something I've missed):
objc2
cratecocoa
objc2-app-kit
cocoa-foundation
objc2-foundation
core-foundation-sys
objc2-core-foundation
core-foundation
objc2-core-foundation
core-graphics-types
objc2-core-foundation
core-graphics
objc2-core-graphics
CGDirectDisplayID
wrapper and most functions are stillunsafe
core-text
objc2-core-text
io-surface
objc2-io-surface
But I do intend to resolve this, so I still feel it's valuable to start discussing migration now.
How
objc2-core-foundation
differs fromcore-foundation
Just to get everyone up to speed, here's a quick overview of the differences.
The memory management strategy is as follows:
core-foundation
objc2-core-foundation
CFString
CFRetained<CFString>
&CFString
&CFRetained<CFString>
CFStringRef
*mut CFString
__CFString
CFString
&CFString
That is,
objc2-core-foundation
only has a single type that representsCFString
, and memory management (CFRetain
/CFRelease
) is instead handled by a single generic wrapper type. This also meant that while I did initially consider building uponcore-foundation
instead of creating a new crate, it wasn't really an option in the end, as the internals are just too different.objc2-core-foundation
also avoids the*-sys
split, instead preferring to expose everything in the same crate (again, to avoid a proliferation of types). A few of my guiding principles API-wise:extern "C" { ... }
themselves.CFURL -> String
conversion, since that requires at least two CoreFoundation functions to be called. Instead,CFURL -> CFString
is provided, and so isCFString -> String
.The text was updated successfully, but these errors were encountered: