mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-28 01:34:21 +00:00
Switch 'native' to 'extern' (or 'foreign' in some descriptions)
This commit is contained in:
parent
7259195caf
commit
debb7e4641
@ -454,7 +454,7 @@ fn content_is_dangerous_to_run(code: str) -> bool {
|
||||
let dangerous_patterns =
|
||||
~["xfail-test",
|
||||
"import", // espeically fs, run
|
||||
"native",
|
||||
"extern",
|
||||
"unsafe",
|
||||
"log"]; // python --> rust pipe deadlock?
|
||||
|
||||
|
@ -9,7 +9,7 @@ export arc, get, clone, shared_arc, get_arc;
|
||||
export exclusive, methods;
|
||||
|
||||
#[abi = "cdecl"]
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
#[rust_stack]
|
||||
fn rust_atomic_increment(p: &mut libc::intptr_t)
|
||||
-> libc::intptr_t;
|
||||
|
@ -17,7 +17,7 @@ import libc::c_double;
|
||||
|
||||
#[link_name = "m"]
|
||||
#[abi = "cdecl"]
|
||||
native mod c_double {
|
||||
extern mod c_double {
|
||||
|
||||
// Alpabetically sorted by link_name
|
||||
|
||||
@ -95,7 +95,7 @@ native mod c_double {
|
||||
|
||||
#[link_name = "m"]
|
||||
#[abi = "cdecl"]
|
||||
native mod c_float {
|
||||
extern mod c_float {
|
||||
|
||||
// Alpabetically sorted by link_name
|
||||
|
||||
|
@ -258,7 +258,7 @@ enum rust_port {}
|
||||
type port_id = int;
|
||||
|
||||
#[abi = "cdecl"]
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn rust_port_id_send(target_port: port_id, data: *()) -> libc::uintptr_t;
|
||||
|
||||
fn new_port(unit_sz: libc::size_t) -> *rust_port;
|
||||
@ -280,7 +280,7 @@ native mod rustrt {
|
||||
}
|
||||
|
||||
#[abi = "rust-intrinsic"]
|
||||
native mod rusti {
|
||||
extern mod rusti {
|
||||
fn init<T>() -> T;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ import libc::consts::os::extra::*;
|
||||
type fd_t = c_int;
|
||||
|
||||
#[abi = "cdecl"]
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn rust_get_stdin() -> *libc::FILE;
|
||||
fn rust_get_stdout() -> *libc::FILE;
|
||||
fn rust_get_stderr() -> *libc::FILE;
|
||||
@ -377,11 +377,11 @@ impl of writer for fd_t {
|
||||
}
|
||||
}
|
||||
fn seek(_offset: int, _whence: seek_style) {
|
||||
#error("need 64-bit native calls for seek, sorry");
|
||||
#error("need 64-bit foreign calls for seek, sorry");
|
||||
fail;
|
||||
}
|
||||
fn tell() -> uint {
|
||||
#error("need 64-bit native calls for tell, sorry");
|
||||
#error("need 64-bit foreign calls for tell, sorry");
|
||||
fail;
|
||||
}
|
||||
fn flush() -> int { 0 }
|
||||
|
@ -731,7 +731,7 @@ mod funcs {
|
||||
|
||||
#[nolink]
|
||||
#[abi = "cdecl"]
|
||||
native mod ctype {
|
||||
extern mod ctype {
|
||||
fn isalnum(c: c_int) -> c_int;
|
||||
fn isalpha(c: c_int) -> c_int;
|
||||
fn iscntrl(c: c_int) -> c_int;
|
||||
@ -749,7 +749,7 @@ mod funcs {
|
||||
|
||||
#[nolink]
|
||||
#[abi = "cdecl"]
|
||||
native mod stdio {
|
||||
extern mod stdio {
|
||||
|
||||
fn fopen(filename: *c_char, mode: *c_char) -> *FILE;
|
||||
fn freopen(filename: *c_char, mode: *c_char,
|
||||
@ -793,7 +793,7 @@ mod funcs {
|
||||
|
||||
#[nolink]
|
||||
#[abi = "cdecl"]
|
||||
native mod stdlib {
|
||||
extern mod stdlib {
|
||||
fn abs(i: c_int) -> c_int;
|
||||
fn labs(i: c_long) -> c_long;
|
||||
// Omitted: div, ldiv (return type incomplete).
|
||||
@ -818,7 +818,7 @@ mod funcs {
|
||||
|
||||
#[nolink]
|
||||
#[abi = "cdecl"]
|
||||
native mod string {
|
||||
extern mod string {
|
||||
|
||||
fn strcpy(dst: *c_char, src: *c_char) -> *c_char;
|
||||
fn strncpy(dst: *c_char, src: *c_char, n: size_t) -> *c_char;
|
||||
@ -856,7 +856,7 @@ mod funcs {
|
||||
|
||||
#[nolink]
|
||||
#[abi = "cdecl"]
|
||||
native mod stat {
|
||||
extern mod stat {
|
||||
#[link_name = "_chmod"]
|
||||
fn chmod(path: *c_char, mode: c_int) -> c_int;
|
||||
|
||||
@ -866,7 +866,7 @@ mod funcs {
|
||||
|
||||
#[nolink]
|
||||
#[abi = "cdecl"]
|
||||
native mod stdio {
|
||||
extern mod stdio {
|
||||
#[link_name = "_popen"]
|
||||
fn popen(command: *c_char, mode: *c_char) -> *FILE;
|
||||
|
||||
@ -882,7 +882,7 @@ mod funcs {
|
||||
|
||||
#[nolink]
|
||||
#[abi = "cdecl"]
|
||||
native mod fcntl {
|
||||
extern mod fcntl {
|
||||
#[link_name = "_open"]
|
||||
fn open(path: *c_char, oflag: c_int, mode: c_int) -> c_int;
|
||||
|
||||
@ -892,13 +892,13 @@ mod funcs {
|
||||
|
||||
#[nolink]
|
||||
#[abi = "cdecl"]
|
||||
native mod dirent {
|
||||
extern mod dirent {
|
||||
// Not supplied at all.
|
||||
}
|
||||
|
||||
#[nolink]
|
||||
#[abi = "cdecl"]
|
||||
native mod unistd {
|
||||
extern mod unistd {
|
||||
#[link_name = "_access"]
|
||||
fn access(path: *c_char, amode: c_int) -> c_int;
|
||||
|
||||
@ -966,7 +966,7 @@ mod funcs {
|
||||
|
||||
#[nolink]
|
||||
#[abi = "cdecl"]
|
||||
native mod stat {
|
||||
extern mod stat {
|
||||
fn chmod(path: *c_char, mode: mode_t) -> c_int;
|
||||
fn fchmod(fd: c_int, mode: mode_t) -> c_int;
|
||||
fn mkdir(path: *c_char, mode: mode_t) -> c_int;
|
||||
@ -975,7 +975,7 @@ mod funcs {
|
||||
|
||||
#[nolink]
|
||||
#[abi = "cdecl"]
|
||||
native mod stdio {
|
||||
extern mod stdio {
|
||||
fn popen(command: *c_char, mode: *c_char) -> *FILE;
|
||||
fn pclose(stream: *FILE) -> c_int;
|
||||
fn fdopen(fd: c_int, mode: *c_char) -> *FILE;
|
||||
@ -984,7 +984,7 @@ mod funcs {
|
||||
|
||||
#[nolink]
|
||||
#[abi = "cdecl"]
|
||||
native mod fcntl {
|
||||
extern mod fcntl {
|
||||
fn open(path: *c_char, oflag: c_int, mode: c_int) -> c_int;
|
||||
fn creat(path: *c_char, mode: mode_t) -> c_int;
|
||||
fn fcntl(fd: c_int, cmd: c_int) -> c_int;
|
||||
@ -992,7 +992,7 @@ mod funcs {
|
||||
|
||||
#[nolink]
|
||||
#[abi = "cdecl"]
|
||||
native mod dirent {
|
||||
extern mod dirent {
|
||||
fn opendir(dirname: *c_char) -> *DIR;
|
||||
fn closedir(dirp: *DIR) -> c_int;
|
||||
fn readdir(dirp: *DIR) -> *dirent;
|
||||
@ -1003,7 +1003,7 @@ mod funcs {
|
||||
|
||||
#[nolink]
|
||||
#[abi = "cdecl"]
|
||||
native mod unistd {
|
||||
extern mod unistd {
|
||||
fn access(path: *c_char, amode: c_int) -> c_int;
|
||||
fn alarm(seconds: c_uint) -> c_uint;
|
||||
fn chdir(dir: *c_char) -> c_int;
|
||||
@ -1056,7 +1056,7 @@ mod funcs {
|
||||
|
||||
#[nolink]
|
||||
#[abi = "cdecl"]
|
||||
native mod unistd {
|
||||
extern mod unistd {
|
||||
fn readlink(path: *c_char, buf: *mut c_char,
|
||||
bufsz: size_t) -> ssize_t;
|
||||
|
||||
@ -1073,7 +1073,7 @@ mod funcs {
|
||||
|
||||
#[nolink]
|
||||
#[abi = "cdecl"]
|
||||
native mod wait {
|
||||
extern mod wait {
|
||||
fn waitpid(pid: pid_t, status: *mut c_int,
|
||||
options: c_int) -> pid_t;
|
||||
}
|
||||
@ -1082,7 +1082,7 @@ mod funcs {
|
||||
#[cfg(target_os = "win32")]
|
||||
mod posix01 {
|
||||
#[nolink]
|
||||
native mod unistd { }
|
||||
extern mod unistd { }
|
||||
}
|
||||
|
||||
|
||||
@ -1092,7 +1092,7 @@ mod funcs {
|
||||
#[cfg(target_os = "freebsd")]
|
||||
mod posix08 {
|
||||
#[nolink]
|
||||
native mod unistd { }
|
||||
extern mod unistd { }
|
||||
}
|
||||
|
||||
|
||||
@ -1100,7 +1100,7 @@ mod funcs {
|
||||
#[cfg(target_os = "freebsd")]
|
||||
#[nolink]
|
||||
#[abi = "cdecl"]
|
||||
native mod bsd44 {
|
||||
extern mod bsd44 {
|
||||
|
||||
fn sysctl(name: *c_int, namelen: c_uint,
|
||||
oldp: *mut c_void, oldlenp: *mut size_t,
|
||||
@ -1124,7 +1124,7 @@ mod funcs {
|
||||
#[cfg(target_os = "macos")]
|
||||
#[nolink]
|
||||
#[abi = "cdecl"]
|
||||
native mod extra {
|
||||
extern mod extra {
|
||||
fn _NSGetExecutablePath(buf: *mut c_char,
|
||||
bufsize: *mut u32) -> c_int;
|
||||
}
|
||||
@ -1141,7 +1141,7 @@ mod funcs {
|
||||
import types::os::arch::extra::*;
|
||||
|
||||
#[abi = "stdcall"]
|
||||
native mod kernel32 {
|
||||
extern mod kernel32 {
|
||||
fn GetEnvironmentVariableW(n: LPCWSTR,
|
||||
v: LPWSTR,
|
||||
nsize: DWORD) -> DWORD;
|
||||
@ -1165,7 +1165,7 @@ mod funcs {
|
||||
|
||||
#[abi = "cdecl"]
|
||||
#[nolink]
|
||||
native mod msvcrt {
|
||||
extern mod msvcrt {
|
||||
#[link_name = "_commit"]
|
||||
fn commit(fd: c_int) -> c_int;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
export console_on, console_off;
|
||||
|
||||
#[nolink]
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn rust_log_console_on();
|
||||
fn rust_log_console_off();
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ export walk_dir;
|
||||
// FIXME: move these to str perhaps? #2620
|
||||
export as_c_charp, fill_charp_buf;
|
||||
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn rust_env_pairs() -> ~[str];
|
||||
fn rust_getcwd() -> str;
|
||||
fn rust_path_is_dir(path: *libc::c_char) -> c_int;
|
||||
@ -135,7 +135,7 @@ mod global_env {
|
||||
export getenv;
|
||||
export setenv;
|
||||
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn rust_global_env_chan_ptr() -> *libc::uintptr_t;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ import compare_and_swap = rustrt::rust_compare_and_swap_ptr;
|
||||
|
||||
type rust_port_id = uint;
|
||||
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn rust_compare_and_swap_ptr(address: *libc::uintptr_t,
|
||||
oldval: libc::uintptr_t,
|
||||
newval: libc::uintptr_t) -> bool;
|
||||
|
@ -19,7 +19,7 @@ import libc::{c_void, size_t};
|
||||
|
||||
#[nolink]
|
||||
#[abi = "cdecl"]
|
||||
native mod libc_ {
|
||||
extern mod libc_ {
|
||||
#[rust_stack]
|
||||
fn memcpy(dest: *c_void, src: *c_void, n: libc::size_t) -> *c_void;
|
||||
#[rust_stack]
|
||||
@ -29,7 +29,7 @@ native mod libc_ {
|
||||
}
|
||||
|
||||
#[abi = "rust-intrinsic"]
|
||||
native mod rusti {
|
||||
extern mod rusti {
|
||||
fn addr_of<T>(val: T) -> *T;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ export xorshift, seeded_xorshift;
|
||||
enum rctx {}
|
||||
|
||||
#[abi = "cdecl"]
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn rand_seed() -> ~[u8];
|
||||
fn rand_new() -> *rctx;
|
||||
fn rand_new_seeded(seed: ~[u8]) -> *rctx;
|
||||
|
@ -10,7 +10,7 @@ export spawn_process;
|
||||
export waitpid;
|
||||
|
||||
#[abi = "cdecl"]
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn rust_run_program(argv: **libc::c_char, envp: *c_void,
|
||||
dir: *libc::c_char,
|
||||
in_fd: c_int, out_fd: c_int, err_fd: c_int)
|
||||
|
@ -34,7 +34,7 @@ fn walk_stack(visit: fn(frame) -> bool) {
|
||||
if *frame_address == 0u {
|
||||
#debug("encountered task_start_wrapper. ending walk");
|
||||
// This is the task_start_wrapper_frame. There is
|
||||
// no stack beneath it and it is a native frame.
|
||||
// no stack beneath it and it is a foreign frame.
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -72,11 +72,11 @@ fn frame_address(f: fn(*u8)) {
|
||||
rusti::frame_address(f)
|
||||
}
|
||||
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn rust_dbg_breakpoint();
|
||||
}
|
||||
|
||||
#[abi = "rust-intrinsic"]
|
||||
native mod rusti {
|
||||
extern mod rusti {
|
||||
fn frame_address(f: fn(*u8));
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ export
|
||||
extensions;
|
||||
|
||||
#[abi = "cdecl"]
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn rust_str_push(&s: str, ch: u8);
|
||||
fn str_reserve_shared(&ss: str, nn: libc::size_t);
|
||||
}
|
||||
@ -1585,7 +1585,7 @@ const tag_six_b: uint = 252u;
|
||||
#[doc = "
|
||||
Work with the byte buffer of a string.
|
||||
|
||||
Allows for unsafe manipulation of strings, which is useful for native
|
||||
Allows for unsafe manipulation of strings, which is useful for foreign
|
||||
interop.
|
||||
|
||||
# Example
|
||||
@ -1604,7 +1604,7 @@ pure fn as_bytes<T>(s: str, f: fn(~[u8]) -> T) -> T {
|
||||
#[doc = "
|
||||
Work with the byte buffer of a string.
|
||||
|
||||
Allows for unsafe manipulation of strings, which is useful for native
|
||||
Allows for unsafe manipulation of strings, which is useful for foreign
|
||||
interop.
|
||||
"]
|
||||
pure fn as_buf<T>(s: str, f: fn(*u8) -> T) -> T {
|
||||
@ -1614,7 +1614,7 @@ pure fn as_buf<T>(s: str, f: fn(*u8) -> T) -> T {
|
||||
#[doc = "
|
||||
Work with the byte buffer of a string as a null-terminated C string.
|
||||
|
||||
Allows for unsafe manipulation of strings, which is useful for native
|
||||
Allows for unsafe manipulation of strings, which is useful for foreign
|
||||
interop, without copying the original string.
|
||||
|
||||
# Example
|
||||
|
@ -19,7 +19,7 @@ enum type_desc = {
|
||||
type rust_cond_lock = *libc::c_void;
|
||||
|
||||
#[abi = "cdecl"]
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn unsupervise();
|
||||
pure fn shape_log_str(t: *sys::type_desc, data: *()) -> str;
|
||||
|
||||
@ -32,7 +32,7 @@ native mod rustrt {
|
||||
}
|
||||
|
||||
#[abi = "rust-intrinsic"]
|
||||
native mod rusti {
|
||||
extern mod rusti {
|
||||
fn get_tydesc<T>() -> *();
|
||||
fn size_of<T>() -> uint;
|
||||
fn pref_align_of<T>() -> uint;
|
||||
|
@ -609,7 +609,7 @@ type local_data_key<T> = fn@(+@T);
|
||||
// We use dvec because it's the best data structure in core. If TLS is used
|
||||
// heavily in future, this could be made more efficient with a proper map.
|
||||
type task_local_element = (*libc::c_void, *libc::c_void, fn@(+*libc::c_void));
|
||||
// Has to be a pointer at the outermost layer; the native call returns void *.
|
||||
// Has to be a pointer at outermost layer; the foreign call returns void *.
|
||||
type task_local_map = @dvec::dvec<option<task_local_element>>;
|
||||
|
||||
crust fn cleanup_task_local_map(map_ptr: *libc::c_void) unsafe {
|
||||
@ -763,7 +763,7 @@ unsafe fn local_data_modify<T>(key: local_data_key<T>,
|
||||
local_modify(rustrt::rust_get_task(), key, modify_fn)
|
||||
}
|
||||
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
#[rust_stack]
|
||||
fn rust_task_yield(task: *rust_task, &killed: bool);
|
||||
|
||||
@ -989,7 +989,7 @@ fn test_spawn_sched_childs_on_same_sched() {
|
||||
|
||||
#[nolink]
|
||||
#[cfg(test)]
|
||||
native mod testrt {
|
||||
extern mod testrt {
|
||||
fn rust_dbg_lock_create() -> *libc::c_void;
|
||||
fn rust_dbg_lock_destroy(lock: *libc::c_void);
|
||||
fn rust_dbg_lock_lock(lock: *libc::c_void);
|
||||
|
@ -3,7 +3,7 @@
|
||||
export reinterpret_cast, forget, bump_box_refcount, transmute;
|
||||
|
||||
#[abi = "rust-intrinsic"]
|
||||
native mod rusti {
|
||||
extern mod rusti {
|
||||
fn forget<T>(-x: T);
|
||||
fn reinterpret_cast<T, U>(e: T) -> U;
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ export u8;
|
||||
export extensions;
|
||||
|
||||
#[abi = "cdecl"]
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn vec_reserve_shared(++t: *sys::type_desc,
|
||||
++v: **unsafe::vec_repr,
|
||||
++n: libc::size_t);
|
||||
@ -95,7 +95,7 @@ native mod rustrt {
|
||||
}
|
||||
|
||||
#[abi = "rust-intrinsic"]
|
||||
native mod rusti {
|
||||
extern mod rusti {
|
||||
fn move_val_init<T>(&dst: T, -src: T);
|
||||
}
|
||||
|
||||
@ -1125,8 +1125,8 @@ pure fn windowed<TT: copy>(nn: uint, xx: &[TT]) -> ~[~[TT]] {
|
||||
#[doc = "
|
||||
Work with the buffer of a vector.
|
||||
|
||||
Allows for unsafe manipulation of vector contents, which is useful for native
|
||||
interop.
|
||||
Allows for unsafe manipulation of vector contents, which is useful for
|
||||
foreign interop.
|
||||
"]
|
||||
fn as_buf<E,T>(v: &[E], f: fn(*E) -> T) -> T {
|
||||
unpack_slice(v, |buf, _len| f(buf))
|
||||
|
@ -32,7 +32,7 @@ export len;
|
||||
export ptr;
|
||||
|
||||
#[doc = "
|
||||
The type representing a native chunk of memory
|
||||
The type representing a foreign chunk of memory
|
||||
|
||||
Wrapped in a enum for opacity; FIXME #818 when it is possible to have
|
||||
truly opaque types, this should be revisited.
|
||||
@ -57,11 +57,11 @@ class dtor_res {
|
||||
*/
|
||||
|
||||
#[doc = "
|
||||
Create a `c_vec` from a native buffer with a given length.
|
||||
Create a `c_vec` from a foreign buffer with a given length.
|
||||
|
||||
# Arguments
|
||||
|
||||
* base - A native pointer to a buffer
|
||||
* base - A foreign pointer to a buffer
|
||||
* len - The number of elements in the buffer
|
||||
"]
|
||||
unsafe fn c_vec<T>(base: *mut T, len: uint) -> c_vec<T> {
|
||||
@ -73,12 +73,12 @@ unsafe fn c_vec<T>(base: *mut T, len: uint) -> c_vec<T> {
|
||||
}
|
||||
|
||||
#[doc = "
|
||||
Create a `c_vec` from a native buffer, with a given length,
|
||||
Create a `c_vec` from a foreign buffer, with a given length,
|
||||
and a function to run upon destruction.
|
||||
|
||||
# Arguments
|
||||
|
||||
* base - A native pointer to a buffer
|
||||
* base - A foreign pointer to a buffer
|
||||
* len - The number of elements in the buffer
|
||||
* dtor - A function to run when the value is destructed, useful
|
||||
for freeing the buffer, etc.
|
||||
|
@ -11,7 +11,7 @@ export ptr_cast;
|
||||
export breakpoint;
|
||||
|
||||
#[abi = "cdecl"]
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn debug_tydesc(td: *sys::type_desc);
|
||||
fn debug_opaque(td: *sys::type_desc, x: *());
|
||||
fn debug_box(td: *sys::type_desc, x: *());
|
||||
|
@ -28,7 +28,7 @@ export listen, accept;
|
||||
export connect;
|
||||
|
||||
#[nolink]
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn rust_uv_current_kernel_malloc(size: libc::c_uint) -> *libc::c_void;
|
||||
fn rust_uv_current_kernel_free(mem: *libc::c_void);
|
||||
fn rust_uv_helper_uv_tcp_t_size() -> libc::c_uint;
|
||||
|
@ -22,7 +22,7 @@ export tr_ignored;
|
||||
export run_tests_console;
|
||||
|
||||
#[abi = "cdecl"]
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn sched_threads() -> libc::size_t;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ export
|
||||
strptime;
|
||||
|
||||
#[abi = "cdecl"]
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn get_time(&sec: i64, &nsec: i32);
|
||||
fn precise_time_ns(&ns: u64);
|
||||
|
||||
|
@ -148,7 +148,7 @@ mod icu {
|
||||
|
||||
#[link_name = "icuuc"]
|
||||
#[abi = "cdecl"]
|
||||
native mod libicu {
|
||||
extern mod libicu {
|
||||
pure fn u_hasBinaryProperty(c: UChar32, which: UProperty) -> UBool;
|
||||
pure fn u_isdigit(c: UChar32) -> UBool;
|
||||
pure fn u_islower(c: UChar32) -> UBool;
|
||||
|
@ -12,7 +12,7 @@ import priv::{chan_from_global_ptr, weaken_task};
|
||||
import comm::{port, chan, methods, select2, listen};
|
||||
import either::{left, right};
|
||||
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn rust_uv_get_kernel_global_chan_ptr() -> *libc::uintptr_t;
|
||||
}
|
||||
|
||||
|
@ -556,7 +556,7 @@ mod uv_ll_struct_stubgen {
|
||||
}
|
||||
|
||||
#[nolink]
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
// libuv public API
|
||||
fn rust_uv_loop_new() -> *libc::c_void;
|
||||
fn rust_uv_loop_delete(lp: *libc::c_void);
|
||||
@ -705,7 +705,7 @@ unsafe fn tcp_connect(connect_ptr: *uv_connect_t,
|
||||
addr_ptr: *sockaddr_in,
|
||||
++after_connect_cb: *u8)
|
||||
-> libc::c_int {
|
||||
log(debug, #fmt("b4 native tcp_connect--addr port: %u cb: %u",
|
||||
log(debug, #fmt("b4 foreign tcp_connect--addr port: %u cb: %u",
|
||||
(*addr_ptr).sin_port as uint, after_connect_cb as uint));
|
||||
ret rustrt::rust_uv_tcp_connect(connect_ptr, tcp_handle_ptr,
|
||||
after_connect_cb, addr_ptr);
|
||||
@ -1527,7 +1527,7 @@ mod test {
|
||||
fn test_uv_ll_struct_size_uv_tcp_t() {
|
||||
let foreign_handle_size = rustrt::rust_uv_helper_uv_tcp_t_size();
|
||||
let rust_handle_size = sys::size_of::<uv_tcp_t>();
|
||||
let output = #fmt("uv_tcp_t -- native: %u rust: %u",
|
||||
let output = #fmt("uv_tcp_t -- foreign: %u rust: %u",
|
||||
foreign_handle_size as uint, rust_handle_size);
|
||||
log(debug, output);
|
||||
assert foreign_handle_size as uint == rust_handle_size;
|
||||
@ -1538,7 +1538,7 @@ mod test {
|
||||
let foreign_handle_size =
|
||||
rustrt::rust_uv_helper_uv_connect_t_size();
|
||||
let rust_handle_size = sys::size_of::<uv_connect_t>();
|
||||
let output = #fmt("uv_connect_t -- native: %u rust: %u",
|
||||
let output = #fmt("uv_connect_t -- foreign: %u rust: %u",
|
||||
foreign_handle_size as uint, rust_handle_size);
|
||||
log(debug, output);
|
||||
assert foreign_handle_size as uint == rust_handle_size;
|
||||
@ -1549,7 +1549,7 @@ mod test {
|
||||
let foreign_handle_size =
|
||||
rustrt::rust_uv_helper_uv_buf_t_size();
|
||||
let rust_handle_size = sys::size_of::<uv_buf_t>();
|
||||
let output = #fmt("uv_buf_t -- native: %u rust: %u",
|
||||
let output = #fmt("uv_buf_t -- foreign: %u rust: %u",
|
||||
foreign_handle_size as uint, rust_handle_size);
|
||||
log(debug, output);
|
||||
assert foreign_handle_size as uint == rust_handle_size;
|
||||
@ -1560,7 +1560,7 @@ mod test {
|
||||
let foreign_handle_size =
|
||||
rustrt::rust_uv_helper_uv_write_t_size();
|
||||
let rust_handle_size = sys::size_of::<uv_write_t>();
|
||||
let output = #fmt("uv_write_t -- native: %u rust: %u",
|
||||
let output = #fmt("uv_write_t -- foreign: %u rust: %u",
|
||||
foreign_handle_size as uint, rust_handle_size);
|
||||
log(debug, output);
|
||||
assert foreign_handle_size as uint == rust_handle_size;
|
||||
@ -1572,7 +1572,7 @@ mod test {
|
||||
let foreign_handle_size =
|
||||
rustrt::rust_uv_helper_sockaddr_in_size();
|
||||
let rust_handle_size = sys::size_of::<sockaddr_in>();
|
||||
let output = #fmt("sockaddr_in -- native: %u rust: %u",
|
||||
let output = #fmt("sockaddr_in -- foreign: %u rust: %u",
|
||||
foreign_handle_size as uint, rust_handle_size);
|
||||
log(debug, output);
|
||||
assert foreign_handle_size as uint == rust_handle_size;
|
||||
@ -1583,7 +1583,7 @@ mod test {
|
||||
let native_handle_size =
|
||||
rustrt::rust_uv_helper_sockaddr_in6_size();
|
||||
let rust_handle_size = sys::size_of::<sockaddr_in6>();
|
||||
let output = #fmt("sockaddr_in6 -- native: %u rust: %u",
|
||||
let output = #fmt("sockaddr_in6 -- foreign: %u rust: %u",
|
||||
native_handle_size as uint, rust_handle_size);
|
||||
log(debug, output);
|
||||
// FIXME #1645 .. rust appears to pad structs to the nearest byte..?
|
||||
@ -1598,7 +1598,7 @@ mod test {
|
||||
let native_handle_size =
|
||||
rustrt::rust_uv_helper_addr_in_size();
|
||||
let rust_handle_size = sys::size_of::<addr_in>();
|
||||
let output = #fmt("addr_in -- native: %u rust: %u",
|
||||
let output = #fmt("addr_in -- foreign: %u rust: %u",
|
||||
native_handle_size as uint, rust_handle_size);
|
||||
log(debug, output);
|
||||
// FIXME #1645 .. see note above about struct padding
|
||||
@ -1611,7 +1611,7 @@ mod test {
|
||||
let foreign_handle_size =
|
||||
rustrt::rust_uv_helper_uv_async_t_size();
|
||||
let rust_handle_size = sys::size_of::<uv_async_t>();
|
||||
let output = #fmt("uv_async_t -- native: %u rust: %u",
|
||||
let output = #fmt("uv_async_t -- foreign: %u rust: %u",
|
||||
foreign_handle_size as uint, rust_handle_size);
|
||||
log(debug, output);
|
||||
assert foreign_handle_size as uint == rust_handle_size;
|
||||
@ -1623,7 +1623,7 @@ mod test {
|
||||
let foreign_handle_size =
|
||||
rustrt::rust_uv_helper_uv_timer_t_size();
|
||||
let rust_handle_size = sys::size_of::<uv_timer_t>();
|
||||
let output = #fmt("uv_timer_t -- native: %u rust: %u",
|
||||
let output = #fmt("uv_timer_t -- foreign: %u rust: %u",
|
||||
foreign_handle_size as uint, rust_handle_size);
|
||||
log(debug, output);
|
||||
assert foreign_handle_size as uint == rust_handle_size;
|
||||
@ -1636,7 +1636,7 @@ mod test {
|
||||
let native_handle_size =
|
||||
rustrt::rust_uv_helper_uv_getaddrinfo_t_size();
|
||||
let rust_handle_size = sys::size_of::<uv_getaddrinfo_t>();
|
||||
let output = #fmt("uv_getaddrinfo_t -- native: %u rust: %u",
|
||||
let output = #fmt("uv_getaddrinfo_t -- foreign: %u rust: %u",
|
||||
native_handle_size as uint, rust_handle_size);
|
||||
log(debug, output);
|
||||
assert native_handle_size as uint == rust_handle_size;
|
||||
@ -1649,7 +1649,7 @@ mod test {
|
||||
let native_handle_size =
|
||||
rustrt::rust_uv_helper_addrinfo_size();
|
||||
let rust_handle_size = sys::size_of::<addrinfo>();
|
||||
let output = #fmt("addrinfo -- native: %u rust: %u",
|
||||
let output = #fmt("addrinfo -- foreign: %u rust: %u",
|
||||
native_handle_size as uint, rust_handle_size);
|
||||
log(debug, output);
|
||||
assert native_handle_size as uint == rust_handle_size;
|
||||
|
@ -170,7 +170,7 @@ enum mutability { m_mutbl, m_imm, m_const, }
|
||||
|
||||
#[auto_serialize]
|
||||
enum proto {
|
||||
proto_bare, // native fn
|
||||
proto_bare, // foreign fn
|
||||
proto_any, // fn
|
||||
proto_uniq, // fn~
|
||||
proto_box, // fn@
|
||||
|
@ -270,7 +270,7 @@ fn node_id_to_str(map: map, id: node_id) -> str {
|
||||
#fmt["item %s (id=%?)", path_ident_to_str(*path, item.ident), id]
|
||||
}
|
||||
some(node_foreign_item(item, abi, path)) {
|
||||
#fmt["native item %s with abi %? (id=%?)",
|
||||
#fmt["foreign item %s with abi %? (id=%?)",
|
||||
path_ident_to_str(*path, item.ident), abi, id]
|
||||
}
|
||||
some(node_method(m, impl_did, path)) {
|
||||
|
@ -609,7 +609,7 @@ fn link_binary(sess: session,
|
||||
let ula = cstore::get_used_link_args(cstore);
|
||||
for ula.each |arg| { vec::push(cc_args, arg); }
|
||||
|
||||
// # Native library linking
|
||||
// # Extern library linking
|
||||
|
||||
// User-supplied library search paths (-L on the cammand line) These are
|
||||
// the same paths used to find Rust crates, so some of them may have been
|
||||
@ -620,7 +620,7 @@ fn link_binary(sess: session,
|
||||
let addl_paths = sess.opts.addl_lib_search_paths;
|
||||
for addl_paths.each |path| { vec::push(cc_args, "-L" + path); }
|
||||
|
||||
// The names of the native libraries
|
||||
// The names of the extern libraries
|
||||
let used_libs = cstore::get_used_libraries(cstore);
|
||||
for used_libs.each |l| { vec::push(cc_args, "-l" + l); }
|
||||
|
||||
@ -673,7 +673,7 @@ fn link_binary(sess: session,
|
||||
vec::push(cc_args, "-lmorestack");
|
||||
|
||||
// FIXME (#2397): At some point we want to rpath our guesses as to where
|
||||
// native libraries might live, based on the addl_lib_search_paths
|
||||
// extern libraries might live, based on the addl_lib_search_paths
|
||||
vec::push_all(cc_args, rpath::get_rpath_flags(sess, output));
|
||||
|
||||
#debug("%s link args: %s", cc_prog, str::connect(cc_args, " "));
|
||||
|
@ -27,7 +27,7 @@ fn get_rpath_flags(sess: session::session, out_filename: str) -> ~[str] {
|
||||
let sysroot = sess.filesearch.sysroot();
|
||||
let output = out_filename;
|
||||
let libs = cstore::get_used_crate_files(sess.cstore);
|
||||
// We don't currently rpath native libraries, but we know
|
||||
// We don't currently rpath extern libraries, but we know
|
||||
// where rustrt is and we know every rust program needs it
|
||||
let libs = vec::append_one(libs, get_sysroot_absolute_rt_lib(sess));
|
||||
|
||||
|
@ -121,7 +121,7 @@ mod intrinsic {
|
||||
}
|
||||
|
||||
#[abi = "rust-intrinsic"]
|
||||
native mod rusti {
|
||||
extern mod rusti {
|
||||
fn visit_ty<T>(&&tv: ty_visitor);
|
||||
}
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ type SectionIteratorRef = *SectionIterator_opaque;
|
||||
#[link_args = "-Lrustllvm"]
|
||||
#[link_name = "rustllvm"]
|
||||
#[abi = "cdecl"]
|
||||
native mod llvm {
|
||||
extern mod llvm {
|
||||
/* Create and destroy contexts. */
|
||||
fn LLVMContextCreate() -> ContextRef;
|
||||
fn LLVMGetGlobalContext() -> ContextRef;
|
||||
|
@ -1,6 +1,6 @@
|
||||
#[doc = "
|
||||
|
||||
Validates all used crates and native libraries and loads their metadata
|
||||
Validates all used crates and extern libraries and loads their metadata
|
||||
|
||||
"];
|
||||
|
||||
@ -17,7 +17,7 @@ import dvec::{dvec, extensions};
|
||||
|
||||
export read_crates;
|
||||
|
||||
// Traverses an AST, reading all the information about use'd crates and native
|
||||
// Traverses an AST, reading all the information about use'd crates and extern
|
||||
// libraries necessary for later resolving, typechecking, linking, etc.
|
||||
fn read_crates(diag: span_handler, crate: ast::crate,
|
||||
cstore: cstore::cstore, filesearch: filesearch,
|
||||
|
@ -675,14 +675,14 @@ fn item_family_to_str(fam: char) -> str {
|
||||
'f' { ret "fn"; }
|
||||
'u' { ret "unsafe fn"; }
|
||||
'p' { ret "pure fn"; }
|
||||
'F' { ret "native fn"; }
|
||||
'U' { ret "unsafe native fn"; }
|
||||
'P' { ret "pure native fn"; }
|
||||
'F' { ret "foreign fn"; }
|
||||
'U' { ret "unsafe foreign fn"; }
|
||||
'P' { ret "pure foreign fn"; }
|
||||
'y' { ret "type"; }
|
||||
'T' { ret "native type"; }
|
||||
'T' { ret "foreign type"; }
|
||||
't' { ret "type"; }
|
||||
'm' { ret "mod"; }
|
||||
'n' { ret "native mod"; }
|
||||
'n' { ret "foreign mod"; }
|
||||
'v' { ret "enum"; }
|
||||
'i' { ret "impl"; }
|
||||
'I' { ret "iface"; }
|
||||
|
@ -87,7 +87,7 @@ fn get_lint_dict() -> lint_dict {
|
||||
let v = ~[
|
||||
("ctypes",
|
||||
@{lint: ctypes,
|
||||
desc: "proper use of core::libc types in native modules",
|
||||
desc: "proper use of core::libc types in foreign modules",
|
||||
default: warn}),
|
||||
|
||||
("unused_imports",
|
||||
@ -368,14 +368,14 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {
|
||||
cx.sess.span_lint(
|
||||
ctypes, id, fn_id,
|
||||
ty.span,
|
||||
"found rust type `int` in native module, while \
|
||||
"found rust type `int` in foreign module, while \
|
||||
libc::c_int or libc::c_long should be used");
|
||||
}
|
||||
ast::def_prim_ty(ast::ty_uint(ast::ty_u)) {
|
||||
cx.sess.span_lint(
|
||||
ctypes, id, fn_id,
|
||||
ty.span,
|
||||
"found rust type `uint` in native module, while \
|
||||
"found rust type `uint` in foreign module, while \
|
||||
libc::c_uint or libc::c_ulong should be used");
|
||||
}
|
||||
_ { }
|
||||
|
@ -106,7 +106,7 @@ type indexed_mod = {
|
||||
path: str
|
||||
};
|
||||
|
||||
/* native modules can't contain enums, and we don't store their ASTs because
|
||||
/* foreign modules can't contain enums, and we don't store their ASTs because
|
||||
we only need to look at them to determine exports, which they can't
|
||||
control.*/
|
||||
|
||||
@ -1481,7 +1481,7 @@ fn lookup_in_local_mod(e: env, node_id: node_id, sp: span, id: ident,
|
||||
module %d not in mod_map", node_id)); }
|
||||
};
|
||||
if dr == outside && !is_exported(e, id, inf) {
|
||||
// if we're in a native mod, then dr==inside, so inf.m is some _mod
|
||||
// if we're in a foreign mod, then dr==inside, so inf.m is some _mod
|
||||
ret none; // name is not visible
|
||||
}
|
||||
alt inf.index.find(id) {
|
||||
|
@ -4913,7 +4913,7 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
|
||||
ast::item_fn(decl, tps, body) {
|
||||
if decl.purity == ast::extern_fn {
|
||||
let llfndecl = get_item_val(ccx, item.id);
|
||||
foreign::trans_extern_fn(ccx,
|
||||
foreign::trans_foreign_fn(ccx,
|
||||
vec::append(
|
||||
*path,
|
||||
~[path_name(item.ident)]),
|
||||
@ -5194,7 +5194,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
|
||||
let llfn = if decl.purity != ast::extern_fn {
|
||||
register_fn(ccx, i.span, my_path, i.id)
|
||||
} else {
|
||||
foreign::register_extern_fn(ccx, i.span, my_path, i.id)
|
||||
foreign::register_foreign_fn(ccx, i.span, my_path, i.id)
|
||||
};
|
||||
set_inline_hint_if_appr(i.attrs, llfn);
|
||||
llfn
|
||||
|
@ -19,7 +19,7 @@ import type_of::*;
|
||||
import std::map::hashmap;
|
||||
import util::ppaux::ty_to_str;
|
||||
|
||||
export link_name, trans_foreign_mod, register_extern_fn, trans_extern_fn,
|
||||
export link_name, trans_foreign_mod, register_foreign_fn, trans_foreign_fn,
|
||||
trans_intrinsic;
|
||||
|
||||
enum x86_64_reg_class {
|
||||
@ -541,7 +541,7 @@ fn build_wrap_fn_(ccx: @crate_ctxt,
|
||||
Unreachable(ret_cx);
|
||||
}
|
||||
|
||||
// For each native function F, we generate a wrapper function W and a shim
|
||||
// For each foreign function F, we generate a wrapper function W and a shim
|
||||
// function S that all work together. The wrapper function W is the function
|
||||
// that other rust code actually invokes. Its job is to marshall the
|
||||
// arguments into a struct. It then uses a small bit of assembly to switch
|
||||
@ -549,7 +549,7 @@ fn build_wrap_fn_(ccx: @crate_ctxt,
|
||||
// unpacks the arguments from the struct and invokes the actual function F
|
||||
// according to its specified calling convention.
|
||||
//
|
||||
// Example: Given a native c-stack function F(x: X, y: Y) -> Z,
|
||||
// Example: Given a foreign c-stack function F(x: X, y: Y) -> Z,
|
||||
// we generate a wrapper function W that looks like:
|
||||
//
|
||||
// void W(Z* dest, void *env, X x, Y y) {
|
||||
@ -984,15 +984,15 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item,
|
||||
finish_fn(fcx, lltop);
|
||||
}
|
||||
|
||||
fn trans_extern_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
|
||||
fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
|
||||
body: ast::blk, llwrapfn: ValueRef, id: ast::node_id) {
|
||||
|
||||
let _icx = ccx.insn_ctxt("foreign::build_extern_fn");
|
||||
let _icx = ccx.insn_ctxt("foreign::build_foreign_fn");
|
||||
|
||||
fn build_rust_fn(ccx: @crate_ctxt, path: ast_map::path,
|
||||
decl: ast::fn_decl, body: ast::blk,
|
||||
id: ast::node_id) -> ValueRef {
|
||||
let _icx = ccx.insn_ctxt("foreign::extern::build_rust_fn");
|
||||
let _icx = ccx.insn_ctxt("foreign::foreign::build_rust_fn");
|
||||
let t = ty::node_id_to_type(ccx.tcx, id);
|
||||
let ps = link::mangle_internal_name_by_path(
|
||||
ccx, vec::append_one(path, ast_map::path_name(@"__rust_abi")));
|
||||
@ -1005,7 +1005,7 @@ fn trans_extern_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
|
||||
fn build_shim_fn(ccx: @crate_ctxt, path: ast_map::path,
|
||||
llrustfn: ValueRef, tys: @c_stack_tys) -> ValueRef {
|
||||
|
||||
let _icx = ccx.insn_ctxt("foreign::extern::build_shim_fn");
|
||||
let _icx = ccx.insn_ctxt("foreign::foreign::build_shim_fn");
|
||||
|
||||
fn build_args(bcx: block, tys: @c_stack_tys,
|
||||
llargbundle: ValueRef) -> ~[ValueRef] {
|
||||
@ -1042,11 +1042,11 @@ fn trans_extern_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
|
||||
fn build_wrap_fn(ccx: @crate_ctxt, llshimfn: ValueRef,
|
||||
llwrapfn: ValueRef, tys: @c_stack_tys) {
|
||||
|
||||
let _icx = ccx.insn_ctxt("foreign::extern::build_wrap_fn");
|
||||
let _icx = ccx.insn_ctxt("foreign::foreign::build_wrap_fn");
|
||||
|
||||
fn build_args(bcx: block, tys: @c_stack_tys,
|
||||
llwrapfn: ValueRef, llargbundle: ValueRef) {
|
||||
let _icx = bcx.insn_ctxt("foreign::extern::wrap::build_args");
|
||||
let _icx = bcx.insn_ctxt("foreign::foreign::wrap::build_args");
|
||||
alt tys.x86_64_tys {
|
||||
option::some(x86_64) {
|
||||
let mut atys = x86_64.arg_tys;
|
||||
@ -1100,7 +1100,7 @@ fn trans_extern_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
|
||||
|
||||
fn build_ret(bcx: block, tys: @c_stack_tys,
|
||||
llargbundle: ValueRef) {
|
||||
let _icx = bcx.insn_ctxt("foreign::extern::wrap::build_ret");
|
||||
let _icx = bcx.insn_ctxt("foreign::foreign::wrap::build_ret");
|
||||
alt tys.x86_64_tys {
|
||||
option::some(x86_64) {
|
||||
if x86_64.sret || !tys.ret_def {
|
||||
@ -1137,14 +1137,14 @@ fn trans_extern_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
|
||||
let llrustfn = build_rust_fn(ccx, path, decl, body, id);
|
||||
// The internal shim function - runs on the Rust stack
|
||||
let llshimfn = build_shim_fn(ccx, path, llrustfn, tys);
|
||||
// The external C function - runs on the C stack
|
||||
// The foreign C function - runs on the C stack
|
||||
build_wrap_fn(ccx, llshimfn, llwrapfn, tys)
|
||||
}
|
||||
|
||||
fn register_extern_fn(ccx: @crate_ctxt, sp: span,
|
||||
fn register_foreign_fn(ccx: @crate_ctxt, sp: span,
|
||||
path: ast_map::path, node_id: ast::node_id)
|
||||
-> ValueRef {
|
||||
let _icx = ccx.insn_ctxt("foreign::register_extern_fn");
|
||||
let _icx = ccx.insn_ctxt("foreign::register_foreign_fn");
|
||||
let t = ty::node_id_to_type(ccx.tcx, node_id);
|
||||
let (llargtys, llretty, ret_ty) = c_arg_and_ret_lltys(ccx, node_id);
|
||||
ret if ccx.sess.targ_cfg.arch == arch_x86_64 {
|
||||
|
@ -259,8 +259,8 @@ fn check_main_fn_ty(ccx: @crate_ctxt,
|
||||
if !ok {
|
||||
tcx.sess.span_err(main_span,
|
||||
#fmt("Wrong type in main function: found `%s`, \
|
||||
expecting `native fn(~[str]) -> ()` \
|
||||
or `native fn() -> ()`",
|
||||
expecting `extern fn(~[str]) -> ()` \
|
||||
or `extern fn() -> ()`",
|
||||
ty_to_str(tcx, main_t)));
|
||||
}
|
||||
}
|
||||
|
@ -403,7 +403,7 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) {
|
||||
if (*tpt.bounds).is_not_empty() {
|
||||
ccx.tcx.sess.span_err(
|
||||
item.span,
|
||||
#fmt["native items may not have type parameters"]);
|
||||
#fmt["foreign items may not have type parameters"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -740,8 +740,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
||||
// really hard due to the way that expr_bind() is
|
||||
// written.
|
||||
fcx.ccx.tcx.sess.span_fatal(sp, "mismatched types: \
|
||||
expected function or native \
|
||||
function but found "
|
||||
expected function or foreign \
|
||||
function but found "
|
||||
+ fcx.infcx.ty_to_str(in_fty));
|
||||
}
|
||||
};
|
||||
|
@ -398,7 +398,7 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) {
|
||||
}
|
||||
fn convert_foreign(ccx: @crate_ctxt, i: @ast::foreign_item) {
|
||||
// As above, this call populates the type table with the converted
|
||||
// type of the native item. We simply write it into the node type
|
||||
// type of the foreign item. We simply write it into the node type
|
||||
// table.
|
||||
let tpt = ty_of_foreign_item(ccx, i);
|
||||
alt i.node {
|
||||
|
@ -117,13 +117,13 @@ fn should_extract_top_mod_attributes() {
|
||||
|
||||
#[test]
|
||||
fn should_extract_foreign_mod_attributes() {
|
||||
let doc = test::mk_doc("#[doc = \"test\"] native mod a { }");
|
||||
let doc = test::mk_doc("#[doc = \"test\"] extern mod a { }");
|
||||
assert doc.cratemod().nmods()[0].desc() == some("test");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_extract_foreign_fn_attributes() {
|
||||
let doc = test::mk_doc("native mod a { #[doc = \"test\"] fn a(); }");
|
||||
let doc = test::mk_doc("extern mod a { #[doc = \"test\"] fn a(); }");
|
||||
assert doc.cratemod().nmods()[0].fns[0].desc() == some("test");
|
||||
}
|
||||
|
||||
|
@ -291,13 +291,13 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn extract_foreign_mods() {
|
||||
let doc = mk_doc("native mod a { }");
|
||||
let doc = mk_doc("extern mod a { }");
|
||||
assert doc.cratemod().nmods()[0].name() == "a";
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn extract_fns_from_foreign_mods() {
|
||||
let doc = mk_doc("native mod a { fn a(); }");
|
||||
let doc = mk_doc("extern mod a { fn a(); }");
|
||||
assert doc.cratemod().nmods()[0].fns[0].name() == "a";
|
||||
}
|
||||
|
||||
|
@ -179,10 +179,10 @@ fn should_index_mod_contents_multi_page() {
|
||||
fn should_index_foreign_mod_pages() {
|
||||
let doc = test::mk_doc(
|
||||
config::doc_per_mod,
|
||||
"native mod a { }"
|
||||
"extern mod a { }"
|
||||
);
|
||||
assert option::get(doc.cratemod().index).entries[0] == {
|
||||
kind: "Native module",
|
||||
kind: "Foreign module",
|
||||
name: "a",
|
||||
brief: none,
|
||||
link: "a.html"
|
||||
@ -202,7 +202,7 @@ fn should_add_brief_desc_to_index() {
|
||||
fn should_index_foreign_mod_contents() {
|
||||
let doc = test::mk_doc(
|
||||
config::doc_per_crate,
|
||||
"native mod a { fn b(); }"
|
||||
"extern mod a { fn b(); }"
|
||||
);
|
||||
assert option::get(doc.cratemod().nmods()[0].index).entries[0] == {
|
||||
kind: "Function",
|
||||
|
@ -187,7 +187,7 @@ fn header_kind(doc: doc::itemtag) -> str {
|
||||
}
|
||||
}
|
||||
doc::nmodtag(_) {
|
||||
"Native module"
|
||||
"Foreign module"
|
||||
}
|
||||
doc::fntag(_) {
|
||||
"Function"
|
||||
@ -414,7 +414,7 @@ fn should_not_write_index_if_no_entries() {
|
||||
|
||||
#[test]
|
||||
fn should_write_index_for_foreign_mods() {
|
||||
let markdown = test::render("native mod a { fn a(); }");
|
||||
let markdown = test::render("extern mod a { fn a(); }");
|
||||
assert str::contains(
|
||||
markdown,
|
||||
"\n\n* [Function `a`](#function-a)\n\n"
|
||||
@ -435,20 +435,20 @@ fn write_nmod(ctxt: ctxt, doc: doc::nmoddoc) {
|
||||
|
||||
#[test]
|
||||
fn should_write_foreign_mods() {
|
||||
let markdown = test::render("#[doc = \"test\"] native mod a { }");
|
||||
assert str::contains(markdown, "Native module `a`");
|
||||
let markdown = test::render("#[doc = \"test\"] extern mod a { }");
|
||||
assert str::contains(markdown, "Foreign module `a`");
|
||||
assert str::contains(markdown, "test");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_write_foreign_fns() {
|
||||
let markdown = test::render("native mod a { #[doc = \"test\"] fn a(); }");
|
||||
let markdown = test::render("extern mod a { #[doc = \"test\"] fn a(); }");
|
||||
assert str::contains(markdown, "test");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_write_foreign_fn_headers() {
|
||||
let markdown = test::render("native mod a { #[doc = \"test\"] fn a(); }");
|
||||
let markdown = test::render("extern mod a { #[doc = \"test\"] fn a(); }");
|
||||
assert str::contains(markdown, "## Function `a`");
|
||||
}
|
||||
|
||||
|
@ -150,13 +150,13 @@ fn should_remove_mods_from_containing_mods() {
|
||||
|
||||
#[test]
|
||||
fn should_make_a_page_for_every_foreign_mod() {
|
||||
let doc = test::mk_doc("native mod a { }");
|
||||
let doc = test::mk_doc("extern mod a { }");
|
||||
assert doc.pages.nmods()[0].name() == "a";
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_remove_foreign_mods_from_containing_mods() {
|
||||
let doc = test::mk_doc("native mod a { }");
|
||||
let doc = test::mk_doc("extern mod a { }");
|
||||
assert vec::is_empty(doc.cratemod().nmods());
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ fn should_record_fn_paths() {
|
||||
|
||||
#[test]
|
||||
fn should_record_foreign_mod_paths() {
|
||||
let source = "mod a { native mod b { } }";
|
||||
let source = "mod a { extern mod b { } }";
|
||||
do astsrv::from_str(source) |srv| {
|
||||
let doc = extract::from_srv(srv, "");
|
||||
let doc = run(srv, doc);
|
||||
@ -98,7 +98,7 @@ fn should_record_foreign_mod_paths() {
|
||||
|
||||
#[test]
|
||||
fn should_record_foreign_fn_paths() {
|
||||
let source = "native mod a { fn b(); }";
|
||||
let source = "extern mod a { fn b(); }";
|
||||
do astsrv::from_str(source) |srv| {
|
||||
let doc = extract::from_srv(srv, "");
|
||||
let doc = run(srv, doc);
|
||||
|
@ -446,7 +446,7 @@ fn should_duplicate_reexported_impls_crate() {
|
||||
|
||||
#[test]
|
||||
fn should_duplicate_reexported_foreign_fns() {
|
||||
let source = "native mod a { fn b(); } \
|
||||
let source = "extern mod a { fn b(); } \
|
||||
mod c { import a::b; export b; }";
|
||||
let doc = test::mk_doc(source);
|
||||
assert doc.cratemod().mods()[0].fns()[0].name() == "b";
|
||||
|
@ -25,7 +25,7 @@ fn mk_pass() -> pass {
|
||||
fn test() {
|
||||
let source =
|
||||
"mod imod { } \
|
||||
native mod inmod { } \
|
||||
extern mod inmod { } \
|
||||
const iconst: int = 0; \
|
||||
fn ifn() { } \
|
||||
enum ienum { ivar } \
|
||||
|
@ -69,7 +69,7 @@ fn should_add_fn_sig() {
|
||||
|
||||
#[test]
|
||||
fn should_add_foreign_fn_sig() {
|
||||
let doc = test::mk_doc("native mod a { fn a<T>() -> int; }");
|
||||
let doc = test::mk_doc("extern mod a { fn a<T>() -> int; }");
|
||||
assert doc.cratemod().nmods()[0].fns[0].sig == some("fn a<T>() -> int");
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#[link(name="foreign_lib", vers="0.0")];
|
||||
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn last_os_error() -> str;
|
||||
}
|
@ -87,7 +87,7 @@ enum rust_port {}
|
||||
type port_id = int;
|
||||
|
||||
#[abi = "cdecl"]
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
|
||||
fn new_port(unit_sz: libc::size_t) -> *rust_port;
|
||||
fn del_port(po: *rust_port);
|
||||
@ -100,7 +100,7 @@ native mod rustrt {
|
||||
}
|
||||
|
||||
#[abi = "rust-intrinsic"]
|
||||
native mod rusti {
|
||||
extern mod rusti {
|
||||
fn init<T>() -> T;
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ use std;
|
||||
// stub. Kind of shocking. Might be able to make it faster still with
|
||||
// an llvm intrinsic.
|
||||
#[nolink]
|
||||
native mod libc {
|
||||
extern mod libc {
|
||||
fn sqrt(n: float) -> float;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
// error-pattern:expecting `native fn(~[str])
|
||||
// error-pattern:expecting `extern fn(~[str])
|
||||
|
||||
fn main(x: int) { }
|
||||
|
@ -1,6 +1,6 @@
|
||||
fn main() {
|
||||
let x = 3;
|
||||
fn blah(_a: native fn()) {}
|
||||
fn blah(_a: extern fn()) {}
|
||||
blah(|| {
|
||||
log(debug, x); //~ ERROR attempted dynamic environment capture
|
||||
});
|
||||
|
@ -2,10 +2,10 @@
|
||||
// other tycons.
|
||||
|
||||
fn main() {
|
||||
fn f(f: native fn(native fn(native fn()))) {
|
||||
fn f(f: extern fn(extern fn(extern fn()))) {
|
||||
}
|
||||
|
||||
fn g(f: native fn(fn())) {
|
||||
fn g(f: extern fn(fn())) {
|
||||
}
|
||||
|
||||
f(g);
|
||||
|
@ -1,10 +1,10 @@
|
||||
// Make sure that fn-to-block coercion isn't incorrectly lifted over
|
||||
// other tycons.
|
||||
|
||||
fn coerce(b: fn()) -> native fn() {
|
||||
fn lol(f: native fn(fn()) -> native fn(),
|
||||
g: fn()) -> native fn() { ret f(g); }
|
||||
fn fn_id(f: native fn()) -> native fn() { ret f }
|
||||
fn coerce(b: fn()) -> extern fn() {
|
||||
fn lol(f: extern fn(fn()) -> extern fn(),
|
||||
g: fn()) -> extern fn() { ret f(g); }
|
||||
fn fn_id(f: extern fn()) -> extern fn() { ret f }
|
||||
ret lol(fn_id, b);
|
||||
//~^ ERROR mismatched types: expected `extern fn(fn()) -> extern fn()`
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// error-pattern:expected function or native function but found *u8
|
||||
// error-pattern:expected function or foreign function but found *u8
|
||||
crust fn f() {
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// error-pattern:empty #[link_name] not allowed; use #[nolink].
|
||||
|
||||
#[link_name = ""]
|
||||
native mod foo {
|
||||
extern mod foo {
|
||||
}
|
||||
|
@ -3,5 +3,5 @@
|
||||
|
||||
#[link_name = ""]
|
||||
#[nolink]
|
||||
native mod foo {
|
||||
extern mod foo {
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
// -*- rust -*-
|
||||
|
||||
#[abi = "cdecl"]
|
||||
native mod test {
|
||||
extern mod test {
|
||||
unsafe fn free();
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
// -*- rust -*-
|
||||
|
||||
#[abi = "cdecl"]
|
||||
native mod test {
|
||||
extern mod test {
|
||||
unsafe fn free();
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ the compiler output. */
|
||||
|
||||
#[link_args = "aFdEfSeVEEE"]
|
||||
#[nolink]
|
||||
native mod m1 { }
|
||||
extern mod m1 { }
|
||||
|
||||
fn main() { }
|
@ -8,10 +8,10 @@
|
||||
|
||||
#[link_name= "m"]
|
||||
#[link_args="-foo"] // this could have been elided.
|
||||
native mod m1 {
|
||||
extern mod m1 {
|
||||
}
|
||||
|
||||
#[link_name= "m"]
|
||||
#[link_args="-bar"] // this is the actual error trigger.
|
||||
native mod m2 {
|
||||
extern mod m2 {
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
// error-pattern:unsupported cast
|
||||
|
||||
fn main() {
|
||||
log(debug, 1.0 as *libc::FILE); // Can't cast float to native.
|
||||
log(debug, 1.0 as *libc::FILE); // Can't cast float to foreign.
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
#[warn(err_ctypes)];
|
||||
|
||||
#[nolink]
|
||||
native mod libc {
|
||||
extern mod libc {
|
||||
fn malloc(size: int) -> *u8;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
// compile-flags:-W err-ctypes
|
||||
// error-pattern:found rust type
|
||||
#[nolink]
|
||||
native mod libc {
|
||||
extern mod libc {
|
||||
fn malloc(size: int) -> *u8;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
//error-pattern:libc::c_int or libc::c_long should be used
|
||||
native mod xx {
|
||||
extern mod xx {
|
||||
fn strlen(str: *u8) -> uint;
|
||||
fn foo(x: int, y: uint);
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
// Testing that runtime failure doesn't cause callbacks to abort abnormally.
|
||||
// Instead the failure will be delivered after the callbacks return.
|
||||
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn rust_dbg_call(cb: *u8,
|
||||
data: libc::uintptr_t) -> libc::uintptr_t;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
use std;
|
||||
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn last_os_error() -> str;
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ fn test_fn() {
|
||||
|
||||
#[abi = "cdecl"]
|
||||
#[nolink]
|
||||
native mod test {
|
||||
extern mod test {
|
||||
fn unsupervise();
|
||||
fn get_task_id();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#[abi = "cdecl"]
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn unsupervise();
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ import str;
|
||||
|
||||
#[abi = "cdecl"]
|
||||
#[nolink]
|
||||
native mod libc {
|
||||
extern mod libc {
|
||||
fn atol(x: *u8) -> int;
|
||||
fn atoll(x: *u8) -> i64;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
class cat {
|
||||
let done : native fn(uint);
|
||||
let done : extern fn(uint);
|
||||
let meows : uint;
|
||||
new(done: native fn(uint)) {
|
||||
new(done: extern fn(uint)) {
|
||||
self.meows = 0u;
|
||||
self.done = done;
|
||||
}
|
||||
|
@ -5,14 +5,14 @@ const b: bool = true;
|
||||
|
||||
#[cfg(bogus)]
|
||||
#[abi = "cdecl"]
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
// This symbol doesn't exist and would be a link error if this
|
||||
// module was translated
|
||||
fn bogus();
|
||||
}
|
||||
|
||||
#[abi = "cdecl"]
|
||||
native mod rustrt { }
|
||||
extern mod rustrt { }
|
||||
|
||||
#[cfg(bogus)]
|
||||
type t = int;
|
||||
@ -81,7 +81,7 @@ fn test_in_fn_ctxt() {
|
||||
|
||||
mod test_foreign_items {
|
||||
#[abi = "cdecl"]
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
#[cfg(bogus)]
|
||||
fn vec_from_buf_shared();
|
||||
fn vec_from_buf_shared();
|
||||
|
@ -1,4 +1,4 @@
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn rust_dbg_call(cb: *u8,
|
||||
data: libc::uintptr_t) -> libc::uintptr_t;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn rust_dbg_call(cb: *u8,
|
||||
data: libc::uintptr_t) -> libc::uintptr_t;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
// make sure the stack pointers are maintained properly in both
|
||||
// directions
|
||||
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn rust_dbg_call(cb: *u8,
|
||||
data: libc::uintptr_t) -> libc::uintptr_t;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn rust_dbg_call(cb: *u8,
|
||||
data: libc::uintptr_t) -> libc::uintptr_t;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
// This creates a bunch of yielding tasks that run concurrently
|
||||
// while holding onto C stacks
|
||||
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn rust_dbg_call(cb: *u8,
|
||||
data: libc::uintptr_t) -> libc::uintptr_t;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn rust_dbg_call(cb: *u8,
|
||||
data: libc::uintptr_t) -> libc::uintptr_t;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
|
||||
fn test_fn() {
|
||||
type t = native fn() -> int;
|
||||
type t = extern fn() -> int;
|
||||
fn ten() -> int { ret 10; }
|
||||
let rs: t = { ten };
|
||||
assert (rs() == 10);
|
||||
|
@ -1,8 +1,8 @@
|
||||
fn fix_help<A, B>(f: native fn(fn@(A) -> B, A) -> B, x: A) -> B {
|
||||
fn fix_help<A, B>(f: extern fn(fn@(A) -> B, A) -> B, x: A) -> B {
|
||||
ret f({|a|fix_help(f, a)}, x);
|
||||
}
|
||||
|
||||
fn fix<A, B>(f: native fn(fn@(A) -> B, A) -> B) -> fn@(A) -> B {
|
||||
fn fix<A, B>(f: extern fn(fn@(A) -> B, A) -> B) -> fn@(A) -> B {
|
||||
ret {|a|fix_help(f, a)};
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
fn fix_help<A, B: send>(f: native fn(fn@(A) -> B, A) -> B, x: A) -> B {
|
||||
fn fix_help<A, B: send>(f: extern fn(fn@(A) -> B, A) -> B, x: A) -> B {
|
||||
ret f({|a|fix_help(f, a)}, x);
|
||||
}
|
||||
|
||||
fn fix<A, B: send>(f: native fn(fn@(A) -> B, A) -> B) -> fn@(A) -> B {
|
||||
fn fix<A, B: send>(f: extern fn(fn@(A) -> B, A) -> B) -> fn@(A) -> B {
|
||||
ret {|a|fix_help(f, a)};
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ fn f(i: int, &called: bool) {
|
||||
called = true;
|
||||
}
|
||||
|
||||
fn g(f: native fn(int, &bool), &called: bool) {
|
||||
fn g(f: extern fn(int, &bool), &called: bool) {
|
||||
f(10, called);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// This is what the signature to spawn should look like with bare functions
|
||||
|
||||
fn spawn<T: send>(val: T, f: native fn(T)) {
|
||||
fn spawn<T: send>(val: T, f: extern fn(T)) {
|
||||
f(val);
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
// -*- rust -*-
|
||||
fn foo(f: native fn(int) -> int) { }
|
||||
fn foo(f: extern fn(int) -> int) { }
|
||||
|
||||
fn id(x: int) -> int { ret x; }
|
||||
|
||||
|
@ -3,13 +3,13 @@
|
||||
|
||||
#[abi = "cdecl"]
|
||||
#[link_name = "rustrt"]
|
||||
native mod rustrt1 {
|
||||
extern mod rustrt1 {
|
||||
fn last_os_error() -> str;
|
||||
}
|
||||
|
||||
#[abi = "cdecl"]
|
||||
#[link_name = "rustrt"]
|
||||
native mod rustrt2 {
|
||||
extern mod rustrt2 {
|
||||
fn last_os_error() -> str;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import str;
|
||||
|
||||
#[nolink]
|
||||
#[abi = "cdecl"]
|
||||
native mod libc {
|
||||
extern mod libc {
|
||||
#[link_name = "strlen"]
|
||||
fn my_strlen(str: *u8) -> uint;
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
// xfail-test FIXME I don't know how to test this (#2604)
|
||||
// compile-flags:-L.
|
||||
// The -L flag is also used for linking native libraries
|
||||
// The -L flag is also used for linking foreign libraries
|
||||
|
||||
// FIXME: I want to name a mod that would not link successfully
|
||||
// wouthout providing a -L argument to the compiler, and that
|
||||
// will also be found successfully at runtime.
|
||||
native mod WHATGOESHERE {
|
||||
extern mod WHATGOESHERE {
|
||||
fn IDONTKNOW() -> u32;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
// ABI is cdecl by default
|
||||
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn unsupervise();
|
||||
}
|
||||
|
9
src/test/run-pass/foreign-src/foreign.rs
Normal file
9
src/test/run-pass/foreign-src/foreign.rs
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
|
||||
|
||||
// -*- rust -*-
|
||||
fn main() {
|
||||
libc.puts(rustrt.str_buf("hello, extern world 1"));
|
||||
libc.puts(rustrt.str_buf("hello, extern world 2"));
|
||||
libc.puts(rustrt.str_buf("hello, extern world 3"));
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
enum void { }
|
||||
|
||||
#[nolink]
|
||||
native mod bindgen {
|
||||
extern mod bindgen {
|
||||
fn printf(++v: void);
|
||||
}
|
||||
|
@ -1,27 +1,27 @@
|
||||
|
||||
|
||||
#[abi = "cdecl"]
|
||||
native mod rustrt {
|
||||
extern mod rustrt {
|
||||
fn unsupervise();
|
||||
}
|
||||
|
||||
#[abi = "cdecl"]
|
||||
#[nolink]
|
||||
native mod bar { }
|
||||
extern mod bar { }
|
||||
|
||||
#[abi = "cdecl"]
|
||||
#[nolink]
|
||||
native mod zed { }
|
||||
extern mod zed { }
|
||||
|
||||
#[abi = "cdecl"]
|
||||
#[nolink]
|
||||
native mod libc {
|
||||
extern mod libc {
|
||||
fn write(fd: int, buf: *u8,
|
||||
count: core::libc::size_t) -> core::libc::ssize_t;
|
||||
}
|
||||
|
||||
#[abi = "cdecl"]
|
||||
#[nolink]
|
||||
native mod baz { }
|
||||
extern mod baz { }
|
||||
|
||||
fn main(args: ~[str]) { }
|
@ -5,7 +5,7 @@
|
||||
fn f() -> int { ret 42; }
|
||||
|
||||
fn main() {
|
||||
let g: native fn() -> int = f;
|
||||
let g: extern fn() -> int = f;
|
||||
let i: int = g();
|
||||
assert (i == 42);
|
||||
}
|
||||
|
@ -4,13 +4,13 @@ fn mk() -> int { ret 1; }
|
||||
|
||||
fn chk(&&a: int) { log(debug, a); assert (a == 1); }
|
||||
|
||||
fn apply<T>(produce: native fn() -> T,
|
||||
consume: native fn(T)) {
|
||||
fn apply<T>(produce: extern fn() -> T,
|
||||
consume: extern fn(T)) {
|
||||
consume(produce());
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let produce: native fn() -> int = mk;
|
||||
let consume: native fn(&&int) = chk;
|
||||
let produce: extern fn() -> int = mk;
|
||||
let consume: extern fn(&&int) = chk;
|
||||
apply::<int>(produce, consume);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ mod map_reduce {
|
||||
|
||||
type putter = fn@(str, str);
|
||||
|
||||
type mapper = native fn(str, putter);
|
||||
type mapper = extern fn(str, putter);
|
||||
|
||||
enum ctrl_proto { find_reducer(~[u8], chan<int>), mapper_done, }
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user