From 85ea35e67f7072826d5234ecaf158f2d435ad8fc Mon Sep 17 00:00:00 2001 From: Jack Moffitt Date: Thu, 19 Dec 2013 09:44:43 -0700 Subject: [PATCH] Upgrade to latest Rust. --- appkit.rs | 8 ++------ base.rs | 30 ++++++++---------------------- cocoa.rc | 7 ++----- 3 files changed, 12 insertions(+), 33 deletions(-) diff --git a/appkit.rs b/appkit.rs index 5a34d3a..1b4c59b 100644 --- a/appkit.rs +++ b/appkit.rs @@ -44,13 +44,9 @@ pub struct NSRect { size: NSSize, } -#[nolink] -#[link_args="-framework AppKit"] -extern { - fn NSBeep(); -} +#[link(name = "AppKit", kind = "framework")] +extern {} -#[fixed_stack_segment] pub unsafe fn NSApp() -> id { "NSApplication".send("sharedApplication", ()) } diff --git a/base.rs b/base.rs index 706f25f..4d8c4b4 100644 --- a/base.rs +++ b/base.rs @@ -40,7 +40,6 @@ extern { /// A convenience method to convert the name of a class to the class object itself. #[inline] -#[fixed_stack_segment] pub fn class(name: &str) -> id { unsafe { name.to_c_str().with_ref(|c_string| objc_getClass(c_string)) @@ -49,7 +48,6 @@ pub fn class(name: &str) -> id { /// A convenience method to convert the name of a selector to the selector object. #[inline] -#[fixed_stack_segment] pub fn selector(name: &str) -> SEL { unsafe { name.to_c_str().with_ref(|c_string| sel_registerName(c_string)) @@ -87,7 +85,7 @@ impl ObjCMethodCall for id { /// A convenience implementation that allows methods on class names to be called directly, as in: /// /// "NSString".send("alloc") -impl<'self> ObjCMethodCall for &'self str { +impl<'a> ObjCMethodCall for &'a str { unsafe fn send(self, selector: S, args: A) -> id { args.send_args(class(self), selector.as_selector()) } @@ -109,9 +107,8 @@ pub trait ObjCSelector { fn as_selector(self) -> SEL; } -impl<'self> ObjCSelector for &'self str { +impl<'a> ObjCSelector for &'a str { #[inline] - #[fixed_stack_segment] fn as_selector(self) -> SEL { // TODO(pcwalton): Cache somehow. unsafe { @@ -143,7 +140,6 @@ trait ObjCMethodVoidArgs { impl ObjCMethodArgs for () { #[inline] - #[fixed_stack_segment] unsafe fn send_args(self, receiver: id, selector: SEL) -> id { invoke_msg_id(receiver, selector) } @@ -151,7 +147,6 @@ impl ObjCMethodArgs for () { impl ObjCMethodArgs for (id, id, id, id, id) { #[inline] - #[fixed_stack_segment] unsafe fn send_args(self, receiver: id, selector: SEL) -> id { let (first, second, third, fourth, fifth) = self; invoke_msg_id_id_id_id_id_id(receiver, selector, first, second, third, fourth, fifth) @@ -160,7 +155,6 @@ impl ObjCMethodArgs for (id, id, id, id, id) { impl ObjCMethodArgs for NSRect { #[inline] - #[fixed_stack_segment] unsafe fn send_args(self, receiver: id, selector: SEL) -> id { invoke_msg_id_NSRect(receiver, selector, &self) } @@ -168,7 +162,6 @@ impl ObjCMethodArgs for NSRect { impl ObjCMethodDoubleArgs for () { #[inline] - #[fixed_stack_segment] unsafe fn send_double_args(self, receiver: id, selector: SEL) -> f64 { invoke_msg_double(receiver, selector) } @@ -176,7 +169,6 @@ impl ObjCMethodDoubleArgs for () { impl ObjCMethodLongArgs for () { #[inline] - #[fixed_stack_segment] unsafe fn send_long_args(self, receiver: id, selector: SEL) -> c_long { invoke_msg_long(receiver, selector) } @@ -184,7 +176,6 @@ impl ObjCMethodLongArgs for () { impl ObjCMethodVoidArgs for () { #[inline] - #[fixed_stack_segment] unsafe fn send_void_args(self, receiver: id, selector: SEL) { invoke_msg_void(receiver, selector) } @@ -192,7 +183,6 @@ impl ObjCMethodVoidArgs for () { impl ObjCMethodVoidArgs for bool { #[inline] - #[fixed_stack_segment] unsafe fn send_void_args(self, receiver: id, selector: SEL) { invoke_msg_void_bool(receiver, selector, self) } @@ -200,7 +190,6 @@ impl ObjCMethodVoidArgs for bool { impl ObjCMethodVoidArgs for id { #[inline] - #[fixed_stack_segment] unsafe fn send_void_args(self, receiver: id, selector: SEL) { invoke_msg_void_id(receiver, selector, self) } @@ -214,15 +203,13 @@ mod test { use super::*; #[test] - #[fixed_stack_segment] pub fn test_nsapp() { unsafe { - let nsApp = "NSApplication".send("sharedApplication", ()); + let _nsApp = "NSApplication".send("sharedApplication", ()); } } #[test] - #[fixed_stack_segment] pub fn test_custom_obj() { extern fn MyObject_doSomething(this: id, _: SEL) -> id { println("doSomething"); @@ -230,16 +217,16 @@ mod test { } let NSObject = class("NSObject"); - let MyObject = do "MyObject".to_c_str().with_ref |s| { + let MyObject = "MyObject".to_c_str().with_ref(|s| { unsafe { objc_allocateClassPair(NSObject, s, 0 as libc::size_t) } - }; + }); unsafe { let doSomething = selector("doSomething"); - let _ = do "@@:".to_c_str().with_ref |types| { + let _ = "@@:".to_c_str().with_ref(|types| { class_addMethod(MyObject, doSomething, MyObject_doSomething, types) - }; + }); objc_registerClassPair(MyObject); @@ -250,8 +237,7 @@ mod test { } } -#[link_args = "-L. -lmsgsend"] -#[nolink] +#[link(name = "msgsend")] extern { fn invoke_msg_double(theReceiver: id, theSelector: SEL) -> f64; fn invoke_msg_id(theReceiver: id, theSelector: SEL) -> id; diff --git a/cocoa.rc b/cocoa.rc index 325b2c2..6a6f751 100644 --- a/cocoa.rc +++ b/cocoa.rc @@ -7,14 +7,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[link(name = "cocoa", - vers = "0.1", - uuid = "5b7b7262-780d-465d-892c-15eab956dedc", - url = "http://github.com/pcwalton/cocoa")]; +#[crate_id = "github.com/mozilla-servo/rust-cocoa#cocoa:0.1"]; +#[crate_type = "lib"]; #[comment = "The Servo Parallel Browser Project"]; #[license = "MIT"]; -#[crate_type = "lib"]; #[feature(globs)];