Skip to content
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

Fix requirements on values in NSSet and keys in NSDictionary #505

Merged
merged 5 commits into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions crates/header-translator/src/data/AppKit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,8 @@ data! {

// `addChildWindow:ordered:` is not safe, as cycles must be prevented
}

class NSTouch: Immutable {}

class NSUserInterfaceCompressionOptions: Immutable {}
}
2 changes: 2 additions & 0 deletions crates/header-translator/src/data/CloudKit.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
data! {
class CKRecordID: Immutable {}
class CKRecordZoneID: Immutable {}
}
2 changes: 2 additions & 0 deletions crates/header-translator/src/data/Foundation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,6 @@ data! {

class NSURLRequest: ImmutableWithMutableSubclass<Foundation::NSMutableURLRequest> {}
class NSMutableURLRequest: MutableWithImmutableSuperclass<Foundation::NSURLRequest> {}

class NSIndexPath: Immutable {}
}
20 changes: 20 additions & 0 deletions crates/icrate/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
* Added `Send` and `Sync` implementations for a bunch more types (same as the
ones Swift marks as `@Sendable`).
* Made some common methods in `AppKit` safe.
* Added missing `NSCopying` and `NSMutableCopying` zone methods.
* Added `Eq` and `Ord` implementations for `NSNumber`, since its
handling of floating point values allows it.
* Added `NS[Mutable]Dictionary::from_id_slice` and
`NS[Mutable]Dictionary::from_slice`.
* Added `NSMutableDictionary::insert` and `NSMutableSet::insert` which can
be more efficient than the previous insertion methods.

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

### Removed
* **BREAKING**: Removed the `MainThreadMarker` argument from the closure
passed to `MainThreadBound::get_on_main`.
* **BREAKING**: Removed `Foundation::CopyHelper` since it is superseded by
`objc2::mutability::CounterpartOrSelf`.

### Fixed
* **BREAKING**: Added `Eq + Hash` requirement on most `NSDictionary` and
`NSSet` methods, thereby making sure that the types are actually correct
to use in such hashing collections.
* **BREAKING**: Added `HasStableHash` requirement on `NSDictionary` and
`NSSet` creation methods, fixing a long-standing soundess issue.


## icrate 0.0.4 - 2023-07-31
Expand Down
4 changes: 2 additions & 2 deletions crates/icrate/examples/basic_usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ fn main() {

// Create a dictionary mapping strings to objects
let keys = &[string];
let vals = vec![obj];
let dict = NSDictionary::from_keys_and_objects(keys, vals);
let objects = &[obj];
let dict = NSDictionary::from_id_slice(keys, objects);
println!("{:?}", dict.get(string));
println!("{}", dict.len());
}
Loading