Skip to content

Commit

Permalink
Auto merge of servo#176 - ratake:master, r=jdm
Browse files Browse the repository at this point in the history
Compile NSValue on macOS only

Because it depends on `NSSize`/`NSPoint`. This fixes the build on iOS.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/176)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo authored Nov 1, 2017
2 parents 1d36994 + f37a465 commit 16cf14c
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 16cf14c

Please sign in to comment.