From f37a465990e9835dc8bf95b44566f40123a2f579 Mon Sep 17 00:00:00 2001 From: ratake <32758555+ratake@users.noreply.github.com> Date: Mon, 30 Oct 2017 21:08:52 -0700 Subject: [PATCH] Compile NSValue on macOS only Because it depends on NSSize/NSPoint. This fixes the build on iOS. --- src/foundation.rs | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/foundation.rs b/src/foundation.rs index 90d3b15bc..71a3f5d59 100644 --- a/src/foundation.rs +++ b/src/foundation.rs @@ -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; @@ -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")] @@ -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]