]> git.lizzy.rs Git - rust.git/commitdiff
Use attributes for native module ABI and link name
authorHaitao Li <lihaitao@gmail.com>
Thu, 17 Nov 2011 04:49:38 +0000 (22:49 -0600)
committerBrian Anderson <banderson@mozilla.com>
Wed, 16 Nov 2011 19:35:13 +0000 (11:35 -0800)
This patch changes how to specify ABI and link name of a native module.

Before:
  native "cdecl" mod llvm = "rustllvm" {...}

After:
  #[abi = "cdecl"]
  #[link_name = "rustllvm"]
  native mod llvm {...}

The old optional syntax for ABI and link name is no longer supported.

Fixes issue #547

46 files changed:
src/comp/front/config.rs
src/comp/lib/llvm.rs
src/comp/metadata/creader.rs
src/comp/syntax/ast.rs
src/comp/syntax/fold.rs
src/comp/syntax/parse/parser.rs
src/comp/syntax/print/pprust.rs
src/lib/comm.rs
src/lib/dbg.rs
src/lib/fs.rs
src/lib/io.rs
src/lib/linux_os.rs
src/lib/macos_os.rs
src/lib/math.rs
src/lib/posix_fs.rs
src/lib/ptr.rs
src/lib/rand.rs
src/lib/run_program.rs
src/lib/str.rs
src/lib/sys.rs
src/lib/task.rs
src/lib/test.rs
src/lib/time.rs
src/lib/unicode.rs
src/lib/unsafe.rs
src/lib/vec.rs
src/lib/win32_fs.rs
src/lib/win32_os.rs
src/test/bench/shootout-nbody.rs
src/test/compile-fail/native-unsafe-fn-called.rs
src/test/compile-fail/native-unsafe-fn.rs
src/test/run-pass/bind-native.rs
src/test/run-pass/binops.rs
src/test/run-pass/c-stack-as-value.rs
src/test/run-pass/c-stack-returning-int64.rs
src/test/run-pass/conditional-compile.rs
src/test/run-pass/import-from-native.rs
src/test/run-pass/import-glob-1.rs
src/test/run-pass/interior-vec.rs
src/test/run-pass/issue-506.rs
src/test/run-pass/item-attributes.rs
src/test/run-pass/native-dupe.rs
src/test/run-pass/native-fn-linkname.rs
src/test/run-pass/native-opaque-type.rs
src/test/run-pass/native2.rs
src/test/run-pass/x86stdcall2.rs

index f0eceb093b3b18198456ce1acc34e6844de1612c..26ca6850e8af5d688f3aece0189af1675a5b30a3 100644 (file)
@@ -45,8 +45,7 @@ fn fold_native_mod(cfg: ast::crate_cfg, nm: ast::native_mod,
                    fld: fold::ast_fold) -> ast::native_mod {
     let filter = bind filter_native_item(cfg, _);
     let filtered_items = vec::filter_map(filter, nm.items);
-    ret {native_name: nm.native_name,
-         abi: nm.abi,
+    ret {abi: nm.abi,
          view_items: vec::map(fld.fold_view_item, nm.view_items),
          items: filtered_items};
 }
index 83edf143f335140fdaadb28f8599ab77d760e2f5..68ba8624268ccd8bea688c2308341cdb8594beaa 100644 (file)
 const LLVMRealUNE: uint = 14u;
 
 #[link_args = "-Lrustllvm"]
-native "cdecl" mod llvm = "rustllvm" {
+#[link_name = "rustllvm"]
+#[abi = "cdecl"]
+native mod llvm {
 
     type ModuleRef;
     type ContextRef;
index 95929b3449c88ef935baee83bb5a8e9eddcea73d..f4abe903e13b613fb40490b99a154a197379b4d8 100644 (file)
@@ -54,7 +54,12 @@ fn visit_item(e: env, i: @ast::item) {
             ret;
         }
         let cstore = e.sess.get_cstore();
-        if !cstore::add_used_library(cstore, m.native_name) { ret; }
+        let native_name = i.ident;
+        alt attr::get_meta_item_value_str_by_name(i.attrs, "link_name") {
+          some(nn) { native_name = nn; }
+          none. { }
+        }
+        if !cstore::add_used_library(cstore, native_name) { ret; }
         for a: ast::attribute in
             attr::find_attrs_by_name(i.attrs, "link_args") {
 
index 16d0d0d53c890fc8d2e9caf2478cc5a3727248ff..b2117810c6db61adf3162952b16885b460e4ee1b 100644 (file)
 }
 
 type native_mod =
-    {native_name: str,
+    {// FIXME: Removing abi from AST. Depends on Issue #1179.
      abi: native_abi,
      view_items: [@view_item],
      items: [@native_item]};
index 56e6aecbab1fa2759a57f368400565f70f1af2a3..f9b6d5739c8fea126100e813b2904f80f0b8557a 100644 (file)
@@ -452,8 +452,7 @@ fn noop_fold_mod(m: _mod, fld: ast_fold) -> _mod {
 }
 
 fn noop_fold_native_mod(nm: native_mod, fld: ast_fold) -> native_mod {
-    ret {native_name: nm.native_name,
-         abi: nm.abi,
+    ret {abi: nm.abi,
          view_items: vec::map(fld.fold_view_item, nm.view_items),
          items: vec::map(fld.fold_native_item, nm.items)}
 }
index 580822d9f1d87c10cd4e7d8d7d35cfa21d18fd1d..05f508edfd005bf844dc0280652029814a781c65 100644 (file)
@@ -1978,7 +1978,7 @@ fn parse_native_item(p: parser, attrs: [ast::attribute]) ->
     } else { unexpected(p, p.peek()); }
 }
 
-fn parse_native_mod_items(p: parser, native_name: str, abi: ast::native_abi,
+fn parse_native_mod_items(p: parser, abi: ast::native_abi,
                           first_item_attrs: [ast::attribute]) ->
    ast::native_mod {
     // Shouldn't be any view items since we've already parsed an item attr
@@ -1993,63 +1993,37 @@ fn parse_native_mod_items(p: parser, native_name: str, abi: ast::native_abi,
         initial_attrs = [];
         items += [parse_native_item(p, attrs)];
     }
-    ret {native_name: native_name,
-         abi: abi,
+    ret {abi: abi,
          view_items: view_items,
          items: items};
 }
 
 fn parse_item_native_mod(p: parser, attrs: [ast::attribute]) -> @ast::item {
     let lo = p.get_last_lo_pos();
-    let abi = ast::native_abi_cdecl;
-    if !is_word(p, "mod") {
-        let t = parse_str(p);
-        if str::eq(t, "rust-intrinsic") {
-            abi = ast::native_abi_rust_intrinsic;
-        } else if str::eq(t, "cdecl") {
-            abi = ast::native_abi_cdecl;
-        } else if str::eq(t, "stdcall") {
-            abi = ast::native_abi_stdcall;
-        } else {
-            p.fatal("unsupported abi: " + t);
-        }
-    } else {
-        abi =
-            alt attr::get_meta_item_value_str_by_name(attrs, "abi") {
-              none. { ast::native_abi_cdecl }
-              some("rust-intrinsic") {
-                ast::native_abi_rust_intrinsic
-              }
-              some("cdecl") {
-                ast::native_abi_cdecl
-              }
-              some("stdcall") {
-                ast::native_abi_stdcall
-              }
-              some(t) {
-                p.fatal("unsupported abi: " + t);
-              }
-            };
-    }
     expect_word(p, "mod");
     let id = parse_ident(p);
-    let native_name;
-    if p.peek() == token::EQ {
-        expect(p, token::EQ);
-        native_name = parse_str(p);
-    } else {
-        native_name =
-            alt attr::get_meta_item_value_str_by_name(attrs, "link_name") {
-              none. { id }
-              some(nn) { nn }
-            };
-    }
     expect(p, token::LBRACE);
     let more_attrs = parse_inner_attrs_and_next(p);
     let inner_attrs = more_attrs.inner;
     let first_item_outer_attrs = more_attrs.next;
-    let m =
-        parse_native_mod_items(p, native_name, abi, first_item_outer_attrs);
+    let abi =
+        alt attr::get_meta_item_value_str_by_name(
+                attrs + inner_attrs, "abi") {
+          none. { ast::native_abi_cdecl }
+          some("rust-intrinsic") {
+            ast::native_abi_rust_intrinsic
+          }
+          some("cdecl") {
+            ast::native_abi_cdecl
+          }
+          some("stdcall") {
+            ast::native_abi_stdcall
+          }
+          some(t) {
+            p.fatal("unsupported abi: " + t);
+          }
+        };
+    let m = parse_native_mod_items(p, abi, first_item_outer_attrs);
     let hi = p.get_hi_pos();
     expect(p, token::RBRACE);
     ret mk_item(p, lo, hi, id, ast::item_native_mod(m), attrs + inner_attrs);
index 21cfaa9e072f89cce2a4d497f89325242cfe93fb..93a4293a5d1595fed8ab94ca7588a093649376be 100644 (file)
@@ -395,24 +395,8 @@ fn print_item(s: ps, &&item: @ast::item) {
       }
       ast::item_native_mod(nmod) {
         head(s, "native");
-        alt nmod.abi {
-          ast::native_abi_rust_intrinsic. {
-            word_nbsp(s, "\"rust-intrinsic\"");
-          }
-          ast::native_abi_cdecl. {
-            word_nbsp(s, "\"cdecl\"");
-          }
-          ast::native_abi_stdcall. {
-            word_nbsp(s, "\"stdcall\"");
-          }
-        }
         word_nbsp(s, "mod");
         word_nbsp(s, item.ident);
-        if !str::eq(nmod.native_name, item.ident) {
-            word_space(s, "=");
-            print_string(s, nmod.native_name);
-            nbsp(s);
-        }
         bopen(s);
         print_native_mod(s, nmod, item.attrs);
         bclose(s, item.span);
index 4aca724a01c3bdf275f6d688c93d6dc0102224db..a01db908821c29a1d0f813f717acaa12006f4f60 100644 (file)
@@ -34,7 +34,8 @@
 export chan;
 export port;
 
-native "cdecl" mod rustrt {
+#[abi = "cdecl"]
+native mod rustrt {
     type void;
     type rust_port;
 
@@ -48,7 +49,8 @@ fn chan_id_send<uniq T>(t: *sys::type_desc,
     fn rust_port_size(po: *rust_port) -> ctypes::size_t;
 }
 
-native "rust-intrinsic" mod rusti {
+#[abi = "rust-intrinsic"]
+native mod rusti {
     fn recv<uniq T>(port: *rustrt::rust_port) -> T;
 }
 
index 470341308f2f75f82f071396a41dbcd9d6e3fb60..a6c039d581a809d8ed95217b636aaf2c826a4628 100644 (file)
@@ -8,7 +8,8 @@
  * logging.
  */
 
-native "cdecl" mod rustrt {
+#[abi = "cdecl"]
+native mod rustrt {
     fn debug_tydesc(td: *sys::type_desc);
     fn debug_opaque<T>(td: *sys::type_desc, x: T);
     fn debug_box<T>(td: *sys::type_desc, x: @T);
index 7c8c3ef112851e8e49b4af816d3135855406ee59..d5885a3baec1b9d18eb83796d4a67fbf958b2848 100644 (file)
@@ -7,7 +7,8 @@
 import os::getcwd;
 import os_fs;
 
-native "cdecl" mod rustrt {
+#[abi = "cdecl"]
+native mod rustrt {
     fn rust_file_is_dir(path: str::sbuf) -> int;
 }
 
index afba61423775b51b4d63e659d95308f02d354d95..78a5384db1377ebf61a8510a05a999daa1df17ea 100644 (file)
@@ -1,5 +1,6 @@
 
-native "cdecl" mod rustrt {
+#[abi = "cdecl"]
+native mod rustrt {
     fn rust_get_stdin() -> os::libc::FILE;
     fn rust_get_stdout() -> os::libc::FILE;
     fn rust_get_stderr() -> os::libc::FILE;
index 7a0e097696072f12cd36ec4320b656569f876c3c..c8c4aeed84d2ccdec189cc0d46e8a06eac319f5c 100644 (file)
@@ -6,7 +6,9 @@
 
 // FIXME Somehow merge stuff duplicated here and macosx_os.rs. Made difficult
 // by https://github.com/graydon/rust/issues#issue/268
-native "cdecl" mod libc = "" {
+#[link_name = ""]
+#[abi = "cdecl"]
+native mod libc {
     fn read(fd: int, buf: *u8, count: uint) -> int;
     fn write(fd: int, buf: *u8, count: uint) -> int;
     fn fread(buf: *u8, size: uint, n: uint, f: libc::FILE) -> uint;
@@ -81,7 +83,8 @@ fn waitpid(pid: int) -> int {
     ret status;
 }
 
-native "cdecl" mod rustrt {
+#[abi = "cdecl"]
+native mod rustrt {
     fn rust_getcwd() -> str;
 }
 
index 9bc1fab3c0e7204137b764b2903b76f900e19a65..db93ac649fb87cd20e8ab2197ec086e5d08a989e 100644 (file)
@@ -1,5 +1,7 @@
 
-native "cdecl" mod libc = "" {
+#[link_name = ""]
+#[abi = "cdecl"]
+native mod libc {
     fn read(fd: int, buf: *u8, count: uint) -> int;
     fn write(fd: int, buf: *u8, count: uint) -> int;
     fn fread(buf: *u8, size: uint, n: uint, f: libc::FILE) -> uint;
@@ -74,7 +76,8 @@ fn waitpid(pid: int) -> int {
     ret status;
 }
 
-native "cdecl" mod rustrt {
+#[abi = "cdecl"]
+native mod rustrt {
     fn rust_getcwd() -> str;
 }
 
index fe33b133a86c02686454ae13409d8b92ae5eaa72..6c6a30a0b8ef9b4522e3aafcccf7fc179b0ac5ff 100644 (file)
@@ -1,6 +1,8 @@
 /* Module: math */
 
-native "cdecl" mod libc = "" {
+#[link_name = ""]
+#[abi = "cdecl"]
+native mod libc {
     fn sqrt(n: float) -> float;
     fn sin(n: float) -> float;
     fn asin(n: float) -> float;
index 0966b96d92411be717ab48cb009340c75833b565..fe8dbb4d4f13a8fccd6528382d6ead21b24ada3e 100644 (file)
@@ -1,4 +1,5 @@
-native "cdecl" mod rustrt {
+#[abi = "cdecl"]
+native mod rustrt {
     fn rust_list_files(path: str) -> [str];
 }
 
index df30105b11d5b4a8a2021d2a46faccc68c7cd24e..1654f9188a08f0fb9cd1bcd84ad654b5ae01f96a 100644 (file)
@@ -3,7 +3,8 @@
 
 Unsafe pointer utility functions
 */
-native "rust-intrinsic" mod rusti {
+#[abi = "rust-intrinsic"]
+native mod rusti {
     fn addr_of<T>(val: T) -> *T;
     fn ptr_offset<T>(ptr: *T, count: uint) -> *T;
 }
index 777fdb027bfa4b0793e18226b1710c1f0183cdfd..ae610ae860840047eaa64ce549798117a3e6543e 100644 (file)
@@ -3,7 +3,8 @@
 
 Random number generation
 */
-native "cdecl" mod rustrt {
+#[abi = "cdecl"]
+native mod rustrt {
     type rctx;
     fn rand_new() -> rctx;
     fn rand_next(c: rctx) -> u32;
index f8f84fa40e53edb6c758553b7ec229df79f0dc1d..915e6c0f32535fd101a8671285a17b88c65f638b 100644 (file)
@@ -12,7 +12,8 @@
 export spawn_process;
 export waitpid;
 
-native "cdecl" mod rustrt {
+#[abi = "cdecl"]
+native mod rustrt {
     fn rust_run_program(argv: *sbuf, in_fd: int, out_fd: int, err_fd: int) ->
        int;
 }
index 2d76aa0017ddf8c4d1380cb5bc8eefee72d6874d..4184e8b2050e22324a05228b00ac93929b299a5d 100644 (file)
@@ -16,7 +16,8 @@
        contains, iter_chars, loop_chars, loop_chars_sub,
        escape;
 
-native "cdecl" mod rustrt {
+#[abi = "cdecl"]
+native mod rustrt {
     fn rust_str_push(&s: str, ch: u8);
 }
 
index e7d04c4bcf444558738255da85367c807c17dc66..3ebfae52534572ec1f308b3f5ff81f6db7e49a92 100644 (file)
@@ -7,7 +7,8 @@
     type_desc(@type_desc);
 }
 
-native "cdecl" mod rustrt {
+#[abi = "cdecl"]
+native mod rustrt {
     // Explicitly re-export native stuff we want to be made
     // available outside this crate. Otherwise it's
     // visible-in-crate, but not re-exported.
@@ -19,7 +20,8 @@
     fn unsupervise();
 }
 
-native "rust-intrinsic" mod rusti {
+#[abi = "rust-intrinsic"]
+native mod rusti {
     fn get_type_desc<T>() -> *type_desc;
 }
 
index 3dd4757656208e13e924fdf9d5b7c9d5c408877f..72a73763427c34bf01f92729576d28506d5b043d 100644 (file)
 export spawn_notify;
 export spawn_joinable;
 
-native "rust-intrinsic" mod rusti {
+#[abi = "rust-intrinsic"]
+native mod rusti {
     // these must run on the Rust stack so that they can swap stacks etc:
     fn task_sleep(time_in_us: uint);
 }
 
-native "cdecl" mod rustrt = "rustrt" {
+#[link_name = "rustrt"]
+#[abi = "cdecl"]
+native mod rustrt {
     // these can run on the C stack:
     fn pin_task();
     fn unpin_task();
index daa86bb8b40c78595c92dd1f9cd922196ae4dece..db34b391f2ff174923b9fa163a9d0de3547527ad 100644 (file)
@@ -25,7 +25,8 @@
 export configure_test_task;
 export joinable;
 
-native "cdecl" mod rustrt {
+#[abi = "cdecl"]
+native mod rustrt {
     fn sched_threads() -> uint;
 }
 
index 39ce8c59b681378263ae73ffde495124d3acefad..2865666fdc8390c73ef19c074617a84c4d0885c7 100644 (file)
@@ -4,7 +4,8 @@
 
 // FIXME: Document what these functions do
 
-native "cdecl" mod rustrt {
+#[abi = "cdecl"]
+native mod rustrt {
     fn get_time(&sec: u32, &usec: u32);
     fn nano_time(&ns: u64);
 }
index 3f4452ed7cc575f5029e3dfdb103476f22c59d57..5038721d26e5464a3a877368081663ed31a3b0be 100644 (file)
@@ -148,7 +148,9 @@ mod icu {
     // FIXME: should be -1, change when compiler supports negative
     // constants
 
-    native "cdecl" mod libicu = "icuuc" {
+    #[link_name = "icuuc"]
+    #[abi = "cdecl"]
+    native mod libicu {
         fn u_hasBinaryProperty(c: UChar32, which: UProperty) -> UBool;
     }
 }
index 6db33a4aba2f7e7fdc038aee7268332775d49e65..0162c10ea22b1db4aa8416cf168487b0d96f0dfa 100644 (file)
@@ -4,11 +4,13 @@
 Unsafe operations
 */
 
-native "rust-intrinsic" mod rusti {
+#[abi = "rust-intrinsic"]
+native mod rusti {
     fn cast<T, U>(src: T) -> U;
 }
 
-native "cdecl" mod rustrt {
+#[abi = "cdecl"]
+native mod rustrt {
     fn leak<T>(-thing: T);
 }
 
index 5fc890b535935108b1001ff3625c711fbe56d3d9..3d51560741b220424345d069bacc46b295aee754 100644 (file)
@@ -6,11 +6,13 @@
 import uint::next_power_of_two;
 import ptr::addr_of;
 
-native "rust-intrinsic" mod rusti {
+#[abi = "rust-intrinsic"]
+native mod rusti {
     fn vec_len<T>(&&v: [mutable? T]) -> uint;
 }
 
-native "cdecl" mod rustrt {
+#[abi = "cdecl"]
+native mod rustrt {
     fn vec_reserve_shared<T>(t: *sys::type_desc,
                              &v: [mutable? T],
                              n: uint);
index 12a33cdeeedb294f1b1f88703d32d07148342e9f..6960b836ca4f0ddef9fa929f8b7caa653bb9ab44 100644 (file)
@@ -1,6 +1,7 @@
 
 
-native "cdecl" mod rustrt {
+#[abi = "cdecl"]
+native mod rustrt {
     fn rust_list_files(path: str) -> [str];
 }
 
index 006dd17fa23e42e8e418b6408491cc9bfd9112e5..c7c5f323b11de64da0febc46f09c95c569094809 100644 (file)
@@ -1,5 +1,7 @@
 
-native "cdecl" mod libc = "" {
+#[abi = "cdecl"]
+#[link_name = ""]
+native mod libc {
     fn read(fd: int, buf: *u8, count: uint) -> int;
     fn write(fd: int, buf: *u8, count: uint) -> int;
     fn fread(buf: *u8, size: uint, n: uint, f: libc::FILE) -> uint;
@@ -39,7 +41,8 @@ mod libc_constants {
 type HMODULE = uint;
 type LPTSTR = str::sbuf;
 
-native "stdcall" mod kernel32 {
+#[abi = "stdcall"]
+native mod kernel32 {
     fn GetEnvironmentVariableA(n: str::sbuf, v: str::sbuf, nsize: uint) ->
        uint;
     fn SetEnvironmentVariableA(n: str::sbuf, v: str::sbuf) -> int;
@@ -83,7 +86,8 @@ fn fclose(file: libc::FILE) {
     libc::fclose(file)
 }
 
-native "cdecl" mod rustrt {
+#[abi = "cdecl"]
+native mod rustrt {
     fn rust_process_wait(handle: int) -> int;
     fn rust_getcwd() -> str;
 }
index 72f127976fff8c7a9eeac27a0677a119f823c257..a560e6e1d7a9fddab73965f7e36412cbf5f8116a 100644 (file)
@@ -1,7 +1,9 @@
 // based on:
 // http://shootout.alioth.debian.org/u32/benchmark.php?test=nbody&lang=java
 
-native "cdecl" mod llvm = "" {
+#[abi = "cdecl"]
+#[link_name = ""]
+native mod llvm {
     fn sqrt(n: float) -> float;
 }
 
index 6e9d7ac18fccc7a2c0b62959d35601589445d421..6459a423611b0a5c57a93eb26af0c20bda829e92 100644 (file)
@@ -1,6 +1,7 @@
 // -*- rust -*-
 // error-pattern: safe function calls function marked unsafe
-native "cdecl" mod test {
+#[abi = "cdecl"]
+native mod test {
     unsafe fn free();
 }
 
index 2a2ce4b3246e0402ce2e275036115be102583f85..3d2c0e1f02b03606c8a1cb66050f0ab16aa56227 100644 (file)
@@ -1,7 +1,8 @@
 // -*- rust -*-
 // error-pattern: unsafe functions can only be called
 
-native "cdecl" mod test {
+#[abi = "cdecl"]
+native mod test {
     unsafe fn free();
 }
 
index ecd63a91eebe36d906b38d19a5ba9dc44cf1556d..dddbf575d8075b6071ba0795091306443cc5c012 100644 (file)
@@ -2,7 +2,8 @@
 Can we bind native things?
 */
 
-native "cdecl" mod rustrt {
+#[abi = "cdecl"]
+native mod rustrt {
     fn pin_task();
 }
 
index 2d421947eef294b5787d718cc7f9aad88a7a6532..c627d28e52bc7b711109290c91ee8093b6bc04f6 100644 (file)
@@ -117,7 +117,9 @@ fn h(i: int) { }
     assert (h1 >= h2);
 }
 
-native "cdecl" mod native_mod = "" {
+#[abi = "cdecl"]
+#[link_name = ""]
+native mod test {
     fn do_gc();
     fn unsupervise();
 }
index 2a13e6d35638adc0b03c317ca66a155530493566..d06a6d1b5ea9099fd3828077941f602cda80fff5 100644 (file)
@@ -1,6 +1,7 @@
 // xfail-test
 
-native "cdecl" mod rustrt {
+#[abi = "cdecl"]
+native mod rustrt {
     fn unsupervise();
 }
 
index 278417050475fac67c93f9b1cc42ee99d8a979c5..9d1536c0ce79f02b0fda70ed1ee8951fd76712d2 100644 (file)
@@ -1,7 +1,9 @@
 use std;
 import std::str;
 
-native "cdecl" mod libc = "" {
+#[abi = "cdecl"]
+#[link_name = ""]
+native mod libc {
     fn atol(x: str::sbuf) -> int;
     fn atoll(x: str::sbuf) -> i64;
 }
index 10b9dcd98839dbb04af444576ffd132b228182a8..921f7a2fae78e0545806a9ae8b41570e7860585a 100644 (file)
@@ -4,13 +4,15 @@
 const b: bool = true;
 
 #[cfg(bogus)]
-native "cdecl" mod rustrt {
+#[abi = "cdecl"]
+native mod rustrt {
     // This symbol doesn't exist and would be a link error if this
     // module was translated
     fn bogus();
 }
 
-native "cdecl" mod rustrt { }
+#[abi = "cdecl"]
+native mod rustrt { }
 
 #[cfg(bogus)]
 type t = int;
@@ -79,7 +81,8 @@ fn f() { }
 }
 
 mod test_native_items {
-    native "cdecl" mod rustrt {
+    #[abi = "cdecl"]
+    native mod rustrt {
         #[cfg(bogus)]
         fn vec_from_buf_shared<T>(ptr: *T, count: uint) -> [T];
         fn vec_from_buf_shared<T>(ptr: *T, count: uint) -> [T];
index 4167f89eaa1091c8b287122d69ebb9230cb8fea1..af19142682054a33669e17d9e2ce405a9e2e928a 100644 (file)
@@ -3,7 +3,8 @@ fn ham() { }
     fn eggs() { }
 }
 
-native "cdecl" mod rustrt {
+#[abi = "cdecl"]
+native mod rustrt {
     import spam::{ham, eggs};
     export ham;
     export eggs;
index d9c1b653217b0b528198dd744d5b389435b2b42c..e40d6cbb9cc23b4040cad40e60dbd8e6b726e8be 100644 (file)
@@ -20,7 +20,9 @@ mod b2 {
 //   |   |   |
 mod a2 {
     //   |   |   |
-    native "cdecl" mod b1 = "" {
+    #[abi = "cdecl"]
+    #[link_name = ""]
+    native mod b1 {
         //   |   |   |
         import a1::b2::*;
         //   | <-/  -/
index b28367790464ceb4d007f7f14874cae9726ea2ed..988cea0042fef63dd1af2251e405fbc67313a20f 100644 (file)
@@ -1,6 +1,7 @@
 import rusti::vec_len;
 
-native "rust-intrinsic" mod rusti {
+#[abi = "rust-intrinsic"]
+native mod rusti {
     fn vec_len<T>(&&v: [T]) -> uint;
 }
 
index e8b2d64d7f210cc4c2408e8d2c151ef9876d346f..28f1a92bbf8e9cc0a73d335903569e927dd6cb30 100644 (file)
@@ -10,7 +10,8 @@
 use std;
 import std::task;
 
-native "cdecl" mod rustrt {
+#[abi = "cdecl"]
+native mod rustrt {
     fn task_yield();
 }
 
index 033504e2e0d85c1bca80d5014504d1bd2bb81ece..42874894ab83a553f4c397ca2b0a7a1d06589a2e 100644 (file)
@@ -29,7 +29,8 @@ fn f() { }
     mod mod1 { }
 
     #[attr = "val"]
-    native "cdecl" mod rustrt { }
+    #[abi = "cdecl"]
+    native mod rustrt { }
 
     #[attr = "val"]
     type t = obj { };
@@ -55,7 +56,8 @@ mod mod1 { }
 
     #[attr1 = "val"]
     #[attr2 = "val"]
-    native "cdecl" mod rustrt { }
+    #[abi = "cdecl"]
+    native mod rustrt { }
 
     #[attr1 = "val"]
     #[attr2 = "val"]
@@ -83,7 +85,8 @@ mod mod1 {
         }
 
         #[attr = "val"]
-        native "cdecl" mod rustrt {
+        #[abi = "cdecl"]
+        native mod rustrt {
         }
         */
 
@@ -116,7 +119,8 @@ mod mod1 {
 
         #[attr1 = "val"]
         #[attr2 = "val"]
-        native "cdecl" mod rustrt {
+        #[abi = "cdecl"]
+        native mod rustrt {
         }
         */
 
@@ -182,7 +186,8 @@ fn f() { }
 }
 
 mod test_native_items {
-    native "cdecl" mod rustrt {
+    #[abi = "cdecl"]
+    native mod rustrt {
         #[attr];
 
         #[attr]
index fd0b941980aa690fc6c064d286f84838471ff3ba..22c53fda4f396c33078cb873608f0c506bd1f23a 100644 (file)
@@ -1,11 +1,15 @@
 // xfail-fast - Somehow causes check-fast to livelock?? Probably because we're
 // calling pin_task and that's having wierd side-effects.
 
-native "cdecl" mod rustrt1 = "rustrt" {
+#[abi = "cdecl"]
+#[link_name = "rustrt"]
+native mod rustrt1 {
     fn pin_task();
 }
 
-native "cdecl" mod rustrt2 = "rustrt" {
+#[abi = "cdecl"]
+#[link_name = "rustrt"]
+native mod rustrt2 {
     fn pin_task();
 }
 
index 5dc6faac8980f74ea2700e7a765033410ec10d27..785ec5edda5e3f6f84f06aeaf2504a9e4a3ffc11 100644 (file)
@@ -3,7 +3,9 @@
 import std::vec;
 import std::str;
 
-native "cdecl" mod libc = "" {
+#[link_name = ""]
+#[abi = "cdecl"]
+native mod libc {
     #[link_name = "strlen"]
     fn my_strlen(str: *u8) -> uint;
 }
index 6ec8b4dba6a737a281a56804e755058e05aba6a1..e8df623d1b870677527dd3da80ab29e43092f086 100644 (file)
@@ -1,6 +1,8 @@
 
 
-native "cdecl" mod libc = "" {
+#[abi = "cdecl"]
+#[link_name = ""]
+native mod libc {
     type file_handle;
 }
 
index 03b0038c0d6a781844b80a041e36832f68300752..07cb455cf0fe080f9a247cc498a306e3ddb08fa8 100644 (file)
@@ -1,17 +1,26 @@
 
 
-native "cdecl" mod rustrt {
+#[abi = "cdecl"]
+native mod rustrt {
     fn unsupervise();
 }
 
-native "cdecl" mod bar = "" { }
+#[abi = "cdecl"]
+#[link_name = ""]
+native mod bar { }
 
-native "cdecl" mod zed = "" { }
+#[abi = "cdecl"]
+#[link_name = ""]
+native mod zed { }
 
-native "cdecl" mod libc = "" {
+#[abi = "cdecl"]
+#[link_name = ""]
+native mod libc {
     fn write(fd: int, buf: *u8, count: uint) -> int;
 }
 
-native "cdecl" mod baz = "" { }
+#[abi = "cdecl"]
+#[link_name = ""]
+native mod baz { }
 
 fn main(args: [str]) { }
index 4edb8dc73e03bdeba5dd91ccdbf613a03289d69e..6c5093a1329964f4dc0b9de4c4b99a115d22ccd7 100644 (file)
@@ -5,7 +5,8 @@
 type BOOL = u8;
 
 #[cfg(target_os = "win32")]
-native "stdcall" mod kernel32 {
+#[abi = "stdcall"]
+native mod kernel32 {
        fn GetProcessHeap() -> HANDLE;
        fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) -> LPVOID;
        fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID) -> BOOL;