diff --git a/appkit.rs b/appkit.rs index 54a31b0..3eae4dc 100644 --- a/appkit.rs +++ b/appkit.rs @@ -2,13 +2,13 @@ import base::objc; #[nolink] #[link_args="-framework AppKit"] -native mod appkit { +extern mod appkit { fn NSBeep(); } fn NSApp() -> base::id { - let klass = str::as_c_str("NSApplication") { |s| objc::objc_getClass(s) }; - let sel = str::as_c_str("sharedApplication") { |s| objc::sel_registerName(s) }; + let klass = str::as_c_str("NSApplication", |s| objc::objc_getClass(s)); + let sel = str::as_c_str("sharedApplication", |s| objc::sel_registerName(s)); ret objc::objc_msgSend(klass, sel); } diff --git a/base.rs b/base.rs index d0b1ec6..f25f2e6 100644 --- a/base.rs +++ b/base.rs @@ -8,7 +8,7 @@ type Ivar = libc::intptr_t; const nil : id = 0 as id; -native mod objc { +extern mod objc { fn class_addMethod(cls : Class, name : SEL, imp : IMP, @@ -35,13 +35,13 @@ native mod objc { #[test] fn test_nsapp() { - let klass = str::as_c_str("NSApplication") { |s| + let klass = str::as_c_str("NSApplication", |s| objc::objc_getClass(s) - }; + ); - let sel = str::as_c_str("sharedApplication") { |s| + let sel = str::as_c_str("sharedApplication", |s| objc::sel_registerName(s) - }; + ); let nsapp = objc::objc_msgSend(klass, sel); @@ -50,28 +50,28 @@ fn test_nsapp() { #[test] fn test_custom_obj() { - crust fn MyObject_doSomething(this : id, _sel : SEL) -> id { + extern fn MyObject_doSomething(this : id, _sel : SEL) -> id { io::println("doSomething"); ret this; } - let NSObject = str::as_c_str("NSObject") { |s| + let NSObject = str::as_c_str("NSObject", |s| objc::objc_getClass(s) - }; - let MyObject = str::as_c_str("MyObject") { |s| + ); + let MyObject = str::as_c_str("MyObject", |s| objc::objc_allocateClassPair(NSObject, s, 0 as libc::size_t) - }; - let doSomething = str::as_c_str("doSomething") { |s| + ); + let doSomething = str::as_c_str("doSomething", |s| objc::sel_registerName(s) - }; - let _ = str::as_c_str("@@:") { |types| + ); + let _ = str::as_c_str("@@:", |types| objc::class_addMethod(MyObject, doSomething, MyObject_doSomething, types) - }; + ); objc::objc_registerClassPair(MyObject); - let alloc = str::as_c_str("alloc") { |s| objc::sel_registerName(s) }; - let init = str::as_c_str("init") { |s| objc::sel_registerName(s) }; + let alloc = str::as_c_str("alloc", |s| objc::sel_registerName(s)); + let init = str::as_c_str("init", |s| objc::sel_registerName(s)); let mut obj = objc::objc_msgSend(MyObject, alloc); obj = objc::objc_msgSend(obj, init); diff --git a/cg.rs b/cg.rs index 94409db..055f4d9 100644 --- a/cg.rs +++ b/cg.rs @@ -3,7 +3,7 @@ import libc::{c_void, c_char, size_t}; #[nolink] -native mod cg { +extern mod cg { fn CGDataProviderCreateWithFilename(filename: *c_char) -> CGDataProviderRef; fn CGDataProviderCreateWithData(info: *c_void, data: *c_void, diff --git a/cocoa.rs b/cocoa.rs index 0275e83..8e65e03 100644 --- a/cocoa.rs +++ b/cocoa.rs @@ -5,6 +5,6 @@ fn msgSend1Id(theReceiver: base::id, theSelector: base::SEL, id: base::id) { #[link_args = "-L. -lmsgsend"] #[nolink] -native mod msgsend { +extern mod msgsend { fn msgSend1IdHACK(theReceiver: base::id, theSelector: base::SEL, id: base::id); } diff --git a/foundation.rs b/foundation.rs index b5b2d76..650d1a1 100644 --- a/foundation.rs +++ b/foundation.rs @@ -2,7 +2,7 @@ import base::objc; #[nolink] #[link_args="-framework Foundation"] -native mod foundation { +extern mod foundation { } enum NSAutoreleasePool { @@ -10,12 +10,12 @@ enum NSAutoreleasePool { } fn NSAutoreleasePool() -> base::id { - let klass = str::as_c_str("NSAutoreleasePool") { |s| + let klass = str::as_c_str("NSAutoreleasePool", |s| objc::objc_getClass(s) - }; + ); - let alloc_sel = str::as_c_str("alloc") { |s| objc::sel_registerName(s) }; - let init_sel = str::as_c_str("init") { |s| objc::sel_registerName(s) }; + let alloc_sel = str::as_c_str("alloc", |s| objc::sel_registerName(s)); + let init_sel = str::as_c_str("init", |s| objc::sel_registerName(s)); let pool = objc::objc_msgSend(klass, alloc_sel); ret objc::objc_msgSend(pool, init_sel);