Skip to content

Commit ed7eb95

Browse files
authored
Merge pull request #505 from madsmtm/ensure-stable-hash
Fix requirements on values in `NSSet` and keys in `NSDictionary`
2 parents 112d7b0 + 7c9ff46 commit ed7eb95

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1316
-866
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/header-translator/src/data/AppKit.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,4 +250,8 @@ data! {
250250

251251
// `addChildWindow:ordered:` is not safe, as cycles must be prevented
252252
}
253+
254+
class NSTouch: Immutable {}
255+
256+
class NSUserInterfaceCompressionOptions: Immutable {}
253257
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
data! {
2+
class CKRecordID: Immutable {}
3+
class CKRecordZoneID: Immutable {}
24
}

crates/header-translator/src/data/Foundation.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,4 +241,6 @@ data! {
241241

242242
class NSURLRequest: ImmutableWithMutableSubclass<Foundation::NSMutableURLRequest> {}
243243
class NSMutableURLRequest: MutableWithImmutableSuperclass<Foundation::NSURLRequest> {}
244+
245+
class NSIndexPath: Immutable {}
244246
}

crates/icrate/CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1515
* Added `Send` and `Sync` implementations for a bunch more types (same as the
1616
ones Swift marks as `@Sendable`).
1717
* Made some common methods in `AppKit` safe.
18+
* Added missing `NSCopying` and `NSMutableCopying` zone methods.
19+
* Added `Eq` and `Ord` implementations for `NSNumber`, since its
20+
handling of floating point values allows it.
21+
* Added `NS[Mutable]Dictionary::from_id_slice` and
22+
`NS[Mutable]Dictionary::from_slice`.
23+
* Added `NSMutableDictionary::insert` and `NSMutableSet::insert` which can
24+
be more efficient than the previous insertion methods.
1825

1926
### Changed
2027
* Moved the `ns_string!` macro to `icrate::Foundation::ns_string`. The old
@@ -41,10 +48,23 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
4148
// Do something with `app` and `view`
4249
```
4350
* **BREAKING**: Changed the `NSApp` static to be a function taking `MainThreadMarker`.
51+
* **BREAKING**: Renamed `NS[Mutable]Dictionary::from_keys_and_objects` to
52+
`NS[Mutable]Dictionary::from_vec`.
53+
* **BREAKING**: Renamed `NSMutableDictionary::insert` and
54+
`NSMutableSet::insert` to `insert_id`.
4455

4556
### Removed
4657
* **BREAKING**: Removed the `MainThreadMarker` argument from the closure
4758
passed to `MainThreadBound::get_on_main`.
59+
* **BREAKING**: Removed `Foundation::CopyHelper` since it is superseded by
60+
`objc2::mutability::CounterpartOrSelf`.
61+
62+
### Fixed
63+
* **BREAKING**: Added `Eq + Hash` requirement on most `NSDictionary` and
64+
`NSSet` methods, thereby making sure that the types are actually correct
65+
to use in such hashing collections.
66+
* **BREAKING**: Added `HasStableHash` requirement on `NSDictionary` and
67+
`NSSet` creation methods, fixing a long-standing soundess issue.
4868

4969

5070
## icrate 0.0.4 - 2023-07-31

crates/icrate/examples/basic_usage.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ fn main() {
3636

3737
// Create a dictionary mapping strings to objects
3838
let keys = &[string];
39-
let vals = vec![obj];
40-
let dict = NSDictionary::from_keys_and_objects(keys, vals);
39+
let objects = &[obj];
40+
let dict = NSDictionary::from_id_slice(keys, objects);
4141
println!("{:?}", dict.get(string));
4242
println!("{}", dict.len());
4343
}

0 commit comments

Comments
 (0)