Skip to content

Commit

Permalink
Use objc2 and its framework crates
Browse files Browse the repository at this point in the history
`objc2` is a replacement for `objc`/`objc_id` that contains a bunch of safety improvements, including `msg_send_id!` which automatically upholds memory management rules (`Id::from_ptr`/`Id::from_retained_ptr` is no longer necessary).

Additionally, we use the framework crates `objc2-foundation` and `objc2-app-kit`, which provide for example the `NSPasteboard` type, which has the methods that arboard needs already defined, and with the correct types, ensuring that passing e.g. `Id<NSArray>` and thus accidentally giving away ownership over the array won't happen again.

These crates are automatically generated, ensuring that if you need some obscure API in the future, it's very likely to be there already.
  • Loading branch information
madsmtm authored and complexspaces committed Apr 27, 2024
1 parent 1cca83d commit 0bff1e0
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 127 deletions.
78 changes: 49 additions & 29 deletions Cargo.lock

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

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ clipboard-win = "5.3.1"
log = "0.4"

[target.'cfg(target_os = "macos")'.dependencies]
objc = "0.2"
objc_id = "0.1"
objc-foundation = "0.1"
# Use `relax-void-encoding`, as that allows us to pass `c_void` instead of implementing `Encode` correctly for `&CGImageRef`
objc2 = { version = "0.5.1", features = ["relax-void-encoding"] }
objc2-foundation = { version = "0.2.0", features = ["NSArray", "NSString", "NSEnumerator", "NSGeometry"] }
objc2-app-kit = { version = "0.2.0", features = ["NSPasteboard", "NSPasteboardItem", "NSImage"] }
core-graphics = { version = "0.23", optional = true }
image = { version = "0.25", optional = true, default-features = false, features = ["tiff"] }

Expand Down
Loading

0 comments on commit 0bff1e0

Please sign in to comment.