Skip to content

Commit

Permalink
Remove NSObject special-casing
Browse files Browse the repository at this point in the history
The cases where this triggered was strictly incorrect, and not really
necessary anyway.
  • Loading branch information
madsmtm committed Nov 25, 2024
1 parent 723c865 commit 87dcf25
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 8 deletions.
5 changes: 0 additions & 5 deletions crates/header-translator/src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,6 @@ impl ItemIdentifier {
self.map_name(Some)
}

pub fn is_nsobject(&self) -> bool {
self.library_name() == "objc2"
&& (self.name == "NSObject" || self.name == "NSObjectProtocol")
}

pub fn is_nserror(&self) -> bool {
self.library_name() == "Foundation" && self.name == "NSError"
}
Expand Down
1 change: 0 additions & 1 deletion crates/header-translator/src/rust_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,6 @@ impl Ty {
Self::GenericParam { name } => write!(f, "{name}"),
Self::AnyObject { protocols } => match &**protocols {
[] => write!(f, "AnyObject"),
[decl] if decl.id.is_nsobject() => write!(f, "NSObject"),
[decl] => write!(f, "ProtocolObject<dyn {}>", decl.id.path()),
// TODO: Handle this better
[first, rest @ ..] => {
Expand Down
2 changes: 1 addition & 1 deletion crates/header-translator/src/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1854,7 +1854,7 @@ impl Stmt {
// The object inherits from `NSObject` or `NSProxy` no
// matter what the generic type is, so this must be
// safe.
(_, _) if protocol.is_nsobject() => ("?Sized", None),
("Foundation", "NSObjectProtocol") => ("?Sized", None),
// Encoding and decoding requires that the inner types
// are codable as well.
("Foundation", "NSCoding") => ("?Sized + NSCoding", None),
Expand Down
3 changes: 3 additions & 0 deletions crates/objc2/src/topics/about_generated/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
of `"LAContext"`.
* **BREAKING**: Cfg-gated `HKAudiogramSensitivityPoint` behind
`"HKAudiogramSensitivityPoint"` instead of `"HKAudiogramSample"`.
* **BREAKING**: No longer special-case `NSObjectProtocol` objects. Certain
methods that previously used `&NSObject` for convenience now use the more
correct `&ProtocolObject<dyn NSObjectProtocol>`.

### Deprecated
* Moved `MainThreadMarker` from `objc2-foundation` to `objc2`.
Expand Down

0 comments on commit 87dcf25

Please sign in to comment.