Skip to content

Commit 63755f8

Browse files
authored
Merge pull request #229 from madsmtm/fix-nsvalue
Fix NSValue geometry getters
2 parents 9fa9315 + ca3f90e commit 63755f8

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

objc2/src/foundation/value.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,11 @@ impl NSValue {
141141
pub fn get_point(&self) -> Option<NSPoint> {
142142
if self.contains_encoding::<NSPoint>() {
143143
// SAFETY: We just checked that this contains an NSPoint
144-
#[cfg(any(feature = "gnustep-1-7", target_os = "macos"))]
144+
//
145+
// Note: The documentation says that `pointValue`, `sizeValue` and
146+
// `rectValue` is only available on macOS, but turns out that they
147+
// are actually available everywhere!
145148
let res = unsafe { msg_send![self, pointValue] };
146-
#[cfg(all(feature = "apple", not(target_os = "macos")))]
147-
let res = unsafe { msg_send![self, CGPointValue] };
148149
Some(res)
149150
} else {
150151
None
@@ -154,10 +155,7 @@ impl NSValue {
154155
pub fn get_size(&self) -> Option<NSSize> {
155156
if self.contains_encoding::<NSSize>() {
156157
// SAFETY: We just checked that this contains an NSSize
157-
#[cfg(any(feature = "gnustep-1-7", target_os = "macos"))]
158158
let res = unsafe { msg_send![self, sizeValue] };
159-
#[cfg(all(feature = "apple", not(target_os = "macos")))]
160-
let res = unsafe { msg_send![self, CGSizeValue] };
161159
Some(res)
162160
} else {
163161
None
@@ -167,10 +165,7 @@ impl NSValue {
167165
pub fn get_rect(&self) -> Option<NSRect> {
168166
if self.contains_encoding::<NSRect>() {
169167
// SAFETY: We just checked that this contains an NSRect
170-
#[cfg(any(feature = "gnustep-1-7", target_os = "macos"))]
171168
let res = unsafe { msg_send![self, rectValue] };
172-
#[cfg(all(feature = "apple", not(target_os = "macos")))]
173-
let res = unsafe { msg_send![self, CGRectValue] };
174169
Some(res)
175170
} else {
176171
None

objc2/src/runtime.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ mod tests {
832832
}
833833

834834
#[test]
835-
#[should_panic]
835+
#[should_panic = "NulError"]
836836
fn test_sel_register_null() {
837837
let _ = Sel::register("\0");
838838
}

0 commit comments

Comments
 (0)