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 NSValue geometry getters #229

Merged
merged 1 commit into from
Jul 31, 2022
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
13 changes: 4 additions & 9 deletions objc2/src/foundation/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@ impl NSValue {
pub fn get_point(&self) -> Option<NSPoint> {
if self.contains_encoding::<NSPoint>() {
// SAFETY: We just checked that this contains an NSPoint
#[cfg(any(feature = "gnustep-1-7", target_os = "macos"))]
//
// Note: The documentation says that `pointValue`, `sizeValue` and
// `rectValue` is only available on macOS, but turns out that they
// are actually available everywhere!
let res = unsafe { msg_send![self, pointValue] };
#[cfg(all(feature = "apple", not(target_os = "macos")))]
let res = unsafe { msg_send![self, CGPointValue] };
Some(res)
} else {
None
Expand All @@ -154,10 +155,7 @@ impl NSValue {
pub fn get_size(&self) -> Option<NSSize> {
if self.contains_encoding::<NSSize>() {
// SAFETY: We just checked that this contains an NSSize
#[cfg(any(feature = "gnustep-1-7", target_os = "macos"))]
let res = unsafe { msg_send![self, sizeValue] };
#[cfg(all(feature = "apple", not(target_os = "macos")))]
let res = unsafe { msg_send![self, CGSizeValue] };
Some(res)
} else {
None
Expand All @@ -167,10 +165,7 @@ impl NSValue {
pub fn get_rect(&self) -> Option<NSRect> {
if self.contains_encoding::<NSRect>() {
// SAFETY: We just checked that this contains an NSRect
#[cfg(any(feature = "gnustep-1-7", target_os = "macos"))]
let res = unsafe { msg_send![self, rectValue] };
#[cfg(all(feature = "apple", not(target_os = "macos")))]
let res = unsafe { msg_send![self, CGRectValue] };
Some(res)
} else {
None
Expand Down
2 changes: 1 addition & 1 deletion objc2/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ mod tests {
}

#[test]
#[should_panic]
#[should_panic = "NulError"]
fn test_sel_register_null() {
let _ = Sel::register("\0");
}
Expand Down