After #21 I can go through objc2-foundation and re-evaluate how we should do the ownership stuff. Especially difficult with generic objects like NSArray!
The idea is it we fix the soundness issues in SSheldon/rust-objc-foundation#10, see my comment there.
Probably some rework of INSObject is required.
Should also figure out the safety of "downgrading" (e.g. &MyObject -> &NSObject)? And from there &NSObject -> Id<NSObject, Shared> (which deletes the original lifetime). What about when MyObject<'a> itself carries lifetime information? Maybe add lifetime to Id? Moved to #58
Also, should we add an ObjectType/RetainAble/... type, since not all Message types can actually be used in Id? Moved to #66
Idea:
unsafe trait INSObject {
type Own: Ownership;
// ...
fn new() -> Id<Self, O> { ... }
}
unsafe trait INSCopying: INSObject {
fn copy(&self) -> Id<Self, Shared>;
}
unsafe trait INSMutableCopying: INSObject<Own = Owned> {
fn copy_mut(&self) -> Id<Self, Owned>;
}
unsafe impl INSObject for NSString {
type Own = Shared; // This means there may never exist an `&mut NSString` (and by extension no `Id<NSString, Owned>`)!
}
unsafe impl INSObject for NSMutableString {
type Own = Owned; // Both `Id<NSString, Owned>` and `Id<NSString, Shared>` are possible
}
After #21 I can go through
objc2-foundationand re-evaluate how we should do the ownership stuff. Especially difficult with generic objects likeNSArray!The idea is it we fix the soundness issues in SSheldon/rust-objc-foundation#10, see my comment there.
Probably some rework of
INSObjectis required.Should also figure out the safety of "downgrading" (e.g.Moved to #58&MyObject -> &NSObject)? And from there&NSObject -> Id<NSObject, Shared>(which deletes the original lifetime). What about whenMyObject<'a>itself carries lifetime information? Maybe add lifetime toId?Also, should we add anMoved to #66ObjectType/RetainAble/... type, since not allMessagetypes can actually be used inId?Idea: