Update for recent rust syntax changes.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+5
-5
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user