From a39122e02618bde882c48ed2e6fba66c2ffbabe0 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 27 Mar 2012 15:43:50 -0700 Subject: [PATCH] Initial commit --- appkit.rs | 6 ++++++ base.rs | 22 ++++++++++++++++++++++ cocoa.rc | 14 ++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 appkit.rs create mode 100644 base.rs create mode 100644 cocoa.rc diff --git a/appkit.rs b/appkit.rs new file mode 100644 index 0000000..1ef1132 --- /dev/null +++ b/appkit.rs @@ -0,0 +1,6 @@ +#[nolink] +#[link_args="-framework AppKit"] +native mod appkit { + fn NSBeep(); +} + diff --git a/base.rs b/base.rs new file mode 100644 index 0000000..8004d58 --- /dev/null +++ b/base.rs @@ -0,0 +1,22 @@ +use std; + +type id = libc::intptr_t; +type SEL = libc::intptr_t; + +const nil : id = 0 as id; + +native mod objc { + fn objc_getClass(name : *libc::c_char) -> id; + fn objc_msgSend(theReceiver : id, theSelector : SEL) -> id; + fn sel_registerName(name : *libc::c_char) -> SEL; +} + +#[test] +fn test_nsapp() { + 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 nsapp = objc::objc_msgSend(klass, sel); + + io::println(#fmt("nsapp: %d", (nsapp as int))); +} + diff --git a/cocoa.rc b/cocoa.rc new file mode 100644 index 0000000..cbaa591 --- /dev/null +++ b/cocoa.rc @@ -0,0 +1,14 @@ +#[link(name = "cocoa", + vers = "0.1", + uuid = "5b7b7262-780d-465d-892c-15eab956dedc", + url = "http://github.com/pcwalton/cocoa")]; + +#[comment = "The Servo Parallel Browser Project"]; +#[license = "MIT"]; +#[crate_type = "lib"]; + +use std; + +mod appkit; +mod base; +