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.
Hey, macOS maintainer of
winit
here!I've been working on a replacement for
objc
for around a year now, and am finally getting close to something I'm happy with, see repo, docs and reasons for fork.The selling point for your crates (
cocoa
andcocoa-foundation
) is... Honestly not as strong as I'd like, my improvements mostly benefit higher-level crates and users that try to make a safer API, and your crates don't really do safe. That said, there are reasons, and I think they are enough to outweigh the downsides. I'm opening this PR to get some thoughts on what it would take for you to make the switch, would love to get some feedback!Concrete improvements that directly benefit you:
"verify_message"
feature (planning to enable it withdebug_assertions
) now works, which is why we implementEncode
for a lot of types - this is great for catching bugs, see the first commit in this PR for a few issues I found using this.Object
store anUnsafeCell
- This enables interior mutability ofObject
, meaning that if user code had a&Object
, converted that to*mut Object
and sent a mutating message, this would not be immediate UB.&
- Might not be sound to accessid
behind&id
even ifObject
containsUnsafeCell
- A bit more theoretical, but every bit helps!bool
instead ofBOOL
(done in follow-up PR)NSInteger
/NSUInteger
is nowisize
/usize
(done in follow-up PR)msg_send!
, hopefully new contributors will be less confused."unstable-static-sel"
feature flag for now).Future improvements that could benefit you later on:
msg_send_id!
. Examples: You have to manually callrelease
on the object gotten from+[NSWindow alloc]
+init
and-[NSMenuItem separatorItem]
returns an autoreleased object that really needs to beretain
'ed before use.derive(Encode, RefEncode)
macro so we don't need to do it ourselves, which is error-prone. Not sure what you would think regarding the compile-time cost, so I went for defining a local helper macroimpl_Encode
instead.objc2
bindgen
support so that thecocoa
crate doesn't have to be written manually any more.Downsides:
objc
to help this along!objc
it has still seen less real-world usage.Breaking changes (apart from the obvious "new crate, new types"):
Object
is no longerSend
orSync
, since it may be used to represent objects that aren't (likeNSAutoreleasePool
andNSLock
).bool
instead ofBOOL
(follow-up PR)NSInteger
/NSUInteger
is nowisize
/usize
(follow-up PR)A lot of this is written assuming intimate knowledge of the existing
objc
crate, happy to answer any questions you might have if something is unclear!EDIT: Have added static selectors now.