Skip to content

Commit

Permalink
Compile NSValue on macOS only
Browse files Browse the repository at this point in the history
Because it depends on NSSize/NSPoint. This fixes the build on iOS.
  • Loading branch information
ratake committed Nov 1, 2017
1 parent 1d36994 commit f37a465
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/foundation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const UTF8_ENCODING: usize = 4;
#[cfg(target_os = "macos")]
mod macos {
use std::mem;
use base::{id, class};
use core_graphics::base::CGFloat;
use core_graphics::geometry::CGRect;
use objc;
Expand Down Expand Up @@ -139,6 +140,19 @@ mod macos {
extern {
fn NSInsetRect(rect: NSRect, x: CGFloat, y: CGFloat) -> NSRect;
}

pub trait NSValue: Sized {
unsafe fn valueWithPoint(_: Self, point: NSPoint) -> id {
msg_send![class("NSValue"), valueWithPoint:point]
}

unsafe fn valueWithSize(_: Self, size: NSSize) -> id {
msg_send![class("NSValue"), valueWithSize:size]
}
}

impl NSValue for id {
}
}

#[cfg(target_os = "macos")]
Expand Down Expand Up @@ -200,19 +214,6 @@ impl NSProcessInfo for id {

pub type NSTimeInterval = libc::c_double;

pub trait NSValue: Sized {
unsafe fn valueWithPoint(_: Self, point: NSPoint) -> id {
msg_send![class("NSValue"), valueWithPoint:point]
}

unsafe fn valueWithSize(_: Self, size: NSSize) -> id {
msg_send![class("NSValue"), valueWithSize:size]
}
}

impl NSValue for id {
}

pub trait NSArray: Sized {
unsafe fn array(_: Self) -> id {
msg_send![class("NSArray"), array]
Expand Down

0 comments on commit f37a465

Please sign in to comment.