Permalink
Browse files

Overhaul constructor naming in libs

  • Loading branch information...
1 parent aea8736 commit cd72b1f8481552effb639024494ae4aa4a521fb8 @brson brson committed Mar 12, 2012
Showing with 227 additions and 227 deletions.
  1. +1 −1 src/compiletest/runtest.rs
  2. +1 −1 src/libcore/extfmt.rs
  3. +3 −3 src/libcore/os.rs
  4. +4 −4 src/libcore/rand.rs
  5. +24 −23 src/libcore/task.rs
  6. +15 −15 src/libcore/vec.rs
  7. +4 −4 src/libstd/bitv.rs
  8. +5 −5 src/libstd/c_vec.rs
  9. +1 −1 src/libstd/deque.rs
  10. +1 −2 src/libstd/ebml.rs
  11. +1 −1 src/libstd/getopts.rs
  12. +17 −17 src/libstd/map.rs
  13. +1 −1 src/libstd/md4.rs
  14. +5 −5 src/libstd/rope.rs
  15. +3 −3 src/libstd/serialization.rs
  16. +5 −6 src/libstd/sha1.rs
  17. +1 −1 src/libstd/tempfile.rs
  18. +1 −1 src/libstd/test.rs
  19. +10 −10 src/libstd/treemap.rs
  20. +1 −1 src/libstd/uv.rs
  21. +4 −4 src/rustc/lib/llvm.rs
  22. +6 −6 src/rustc/metadata/astencode.rs
  23. +33 −33 src/rustc/metadata/astencode_gen.rs
  24. +1 −1 src/rustc/metadata/encoder.rs
  25. +3 −3 src/rustc/middle/check_alt.rs
  26. +1 −1 src/rustc/middle/last_use.rs
  27. +2 −2 src/rustc/middle/resolve.rs
  28. +4 −4 src/rustc/middle/trans/alt.rs
  29. +5 −5 src/rustc/middle/trans/base.rs
  30. +3 −3 src/rustc/middle/trans/common.rs
  31. +1 −1 src/rustc/middle/trans/impl.rs
  32. +3 −3 src/rustc/middle/tstate/states.rs
  33. +5 −4 src/rustc/middle/ty.rs
  34. +5 −5 src/rustc/middle/typeck.rs
  35. +1 −1 src/rustc/syntax/ast_util.rs
  36. +3 −3 src/rustc/syntax/print/pp.rs
  37. +1 −1 src/rustc/syntax/util/interner.rs
  38. +1 −1 src/rustc/util/common.rs
  39. +1 −1 src/rustdoc/markdown_pass.rs
  40. +6 −6 src/serializer/serializer.rs
  41. +1 −1 src/test/bench/msgsend.rs
  42. +3 −3 src/test/bench/shootout-fannkuchredux.rs
  43. +1 −1 src/test/bench/shootout-fasta.rs
  44. +1 −1 src/test/bench/shootout-pfib.rs
  45. +3 −3 src/test/bench/shootout-spectralnorm.rs
  46. +4 −4 src/test/bench/sudoku.rs
  47. +2 −2 src/test/bench/task-perf-word-count.rs
  48. +1 −1 src/test/run-fail/unwind-misc-1.rs
  49. +1 −1 src/test/run-pass/import-glob-crate.rs
  50. +1 −1 src/test/run-pass/lots-a-fail.rs
  51. +1 −1 src/test/run-pass/mod-view-items.rs
  52. +1 −1 src/test/run-pass/morestack6.rs
  53. +1 −1 src/test/run-pass/send-iloop.rs
  54. +1 −1 src/test/run-pass/task-comm-12.rs
  55. +1 −1 src/test/run-pass/task-comm-3.rs
  56. +1 −1 src/test/run-pass/task-comm-9.rs
  57. +2 −2 src/test/run-pass/task-comm.rs
  58. +1 −1 src/test/run-pass/task-killjoin.rs
  59. +1 −1 src/test/run-pass/too-much-recursion.rs
  60. +1 −1 src/test/run-pass/unwind-box.rs
  61. +1 −1 src/test/run-pass/unwind-resource.rs
  62. +1 −1 src/test/run-pass/unwind-resource2.rs
  63. +1 −1 src/test/run-pass/unwind-unique.rs
  64. +1 −1 src/test/run-pass/yield.rs
  65. +1 −1 src/test/run-pass/yield1.rs
@@ -226,7 +226,7 @@ fn check_expected_errors(expected_errors: [errors::expected_error],
procres: procres) {
// true if we found the error in question
- let found_flags = vec::to_mut(vec::init_elt(
+ let found_flags = vec::to_mut(vec::from_elem(
vec::len(expected_errors), false));
if procres.status == 0 {
@@ -385,7 +385,7 @@ mod rt {
// FIXME: This might be useful in str: but needs to be utf8 safe first
fn str_init_elt(n_elts: uint, c: char) -> str {
- let svec = vec::init_elt::<u8>(n_elts, c as u8);
+ let svec = vec::from_elem::<u8>(n_elts, c as u8);
ret str::from_bytes(svec);
}
View
@@ -64,7 +64,7 @@ fn as_c_charp<T>(s: str, f: fn(*c_char) -> T) -> T {
fn fill_charp_buf(f: fn(*mutable c_char, size_t) -> bool)
-> option<str> {
- let buf = vec::to_mut(vec::init_elt(tmpbuf_sz, 0u8 as c_char));
+ let buf = vec::to_mut(vec::from_elem(tmpbuf_sz, 0u8 as c_char));
vec::as_mut_buf(buf) { |b|
if f(b, tmpbuf_sz as size_t) {
some(str::from_cstr(b as str::sbuf))
@@ -89,7 +89,7 @@ mod win32 {
let mut res = none;
let mut done = false;
while !done {
- let buf = vec::to_mut(vec::init_elt(n, 0u16));
+ let buf = vec::to_mut(vec::from_elem(n, 0u16));
vec::as_mut_buf(buf) {|b|
let k : dword = f(b, tmpbuf_sz as dword);
if k == (0 as dword) {
@@ -588,7 +588,7 @@ mod tests {
fn make_rand_name() -> str {
import rand;
- let rng: rand::rng = rand::mk_rng();
+ let rng: rand::rng = rand::rng();
let n = "TEST" + rng.gen_str(10u);
assert option::is_none(getenv(n));
n
View
@@ -27,7 +27,7 @@ iface rng {
resource rand_res(c: *rctx) { rustrt::rand_free(c); }
#[doc = "Create a random number generator"]
-fn mk_rng() -> rng {
+fn rng() -> rng {
impl of rng for @rand_res {
fn next() -> u32 { ret rustrt::rand_next(**self); }
fn next_float() -> float {
@@ -70,11 +70,11 @@ mod tests {
#[test]
fn test() {
- let r1: rand::rng = rand::mk_rng();
+ let r1: rand::rng = rand::rng();
log(debug, r1.next());
log(debug, r1.next());
{
- let r2 = rand::mk_rng();
+ let r2 = rand::rng();
log(debug, r1.next());
log(debug, r2.next());
log(debug, r1.next());
@@ -94,7 +94,7 @@ mod tests {
#[test]
fn genstr() {
- let r: rand::rng = rand::mk_rng();
+ let r: rand::rng = rand::rng();
log(debug, r.gen_str(10u));
log(debug, r.gen_str(10u));
log(debug, r.gen_str(10u));
View
@@ -31,7 +31,6 @@ export task_opts;
export task_builder::{};
export default_task_opts;
-export mk_task_builder;
export get_opts;
export set_opts;
export add_wrapper;
@@ -154,11 +153,13 @@ Provides detailed control over the properties and behavior of new tasks.
// when you try to reuse the builder to spawn a new task. We'll just
// sidestep that whole issue by making builder's uncopyable and making
// the run function move them in.
-enum task_builder = {
- mutable opts: task_opts,
- mutable gen_body: fn@(+fn~()) -> fn~(),
- can_not_copy: option<comm::port<()>>
-};
+enum task_builder {
+ task_builder_({
+ mutable opts: task_opts,
+ mutable gen_body: fn@(+fn~()) -> fn~(),
+ can_not_copy: option<comm::port<()>>
+ })
+}
/* Task construction */
@@ -178,12 +179,12 @@ fn default_task_opts() -> task_opts {
}
}
-fn mk_task_builder() -> task_builder {
+fn task_builder() -> task_builder {
#[doc = "Construct a task_builder"];
let body_identity = fn@(+body: fn~()) -> fn~() { body };
- task_builder({
+ task_builder_({
mutable opts: default_task_opts(),
mutable gen_body: body_identity,
can_not_copy: none
@@ -345,10 +346,10 @@ fn spawn(+f: fn~()) {
Sets up a new task with its own call stack and schedules it to run
the provided unique closure.
- This function is equivalent to `run(mk_task_builder(), f)`.
+ This function is equivalent to `run(new_task_builder(), f)`.
"];
- run(mk_task_builder(), f);
+ run(task_builder(), f);
}
fn spawn_listener<A:send>(+f: fn~(comm::port<A>)) -> comm::chan<A> {
@@ -374,10 +375,10 @@ fn spawn_listener<A:send>(+f: fn~(comm::port<A>)) -> comm::chan<A> {
};
// Likewise, the parent has both a 'po' and 'ch'
- This function is equivalent to `run_listener(mk_task_builder(), f)`.
+ This function is equivalent to `run_listener(new_task_builder(), f)`.
"];
- run_listener(mk_task_builder(), f)
+ run_listener(task_builder(), f)
}
fn spawn_sched(mode: sched_mode, +f: fn~()) {
@@ -394,7 +395,7 @@ fn spawn_sched(mode: sched_mode, +f: fn~()) {
greater than zero.
"];
- let mut builder = mk_task_builder();
+ let mut builder = task_builder();
set_opts(builder, {
sched: some({
mode: mode,
@@ -419,7 +420,7 @@ fn try<T:send>(+f: fn~() -> T) -> result::t<T,()> {
let po = comm::port();
let ch = comm::chan(po);
- let mut builder = mk_task_builder();
+ let mut builder = task_builder();
unsupervise(builder);
let result = future_result(builder);
run(builder) {||
@@ -612,7 +613,7 @@ fn test_spawn_raw_notify() {
fn test_run_basic() {
let po = comm::port();
let ch = comm::chan(po);
- let builder = mk_task_builder();
+ let builder = task_builder();
run(builder) {||
comm::send(ch, ());
}
@@ -623,7 +624,7 @@ fn test_run_basic() {
fn test_add_wrapper() {
let po = comm::port();
let ch = comm::chan(po);
- let builder = mk_task_builder();
+ let builder = task_builder();
add_wrapper(builder) {|body|
fn~() {
body();
@@ -637,12 +638,12 @@ fn test_add_wrapper() {
#[test]
#[ignore(cfg(target_os = "win32"))]
fn test_future_result() {
- let builder = mk_task_builder();
+ let builder = task_builder();
let result = future_result(builder);
run(builder) {||}
assert future::get(result) == success;
- let builder = mk_task_builder();
+ let builder = task_builder();
let result = future_result(builder);
unsupervise(builder);
run(builder) {|| fail }
@@ -653,7 +654,7 @@ fn test_future_result() {
fn test_future_task() {
let po = comm::port();
let ch = comm::chan(po);
- let builder = mk_task_builder();
+ let builder = task_builder();
let task1 = future_task(builder);
run(builder) {|| comm::send(ch, get_task()) }
assert future::get(task1) == comm::recv(po);
@@ -849,7 +850,7 @@ fn test_avoid_copying_the_body_spawn_listener() {
#[test]
fn test_avoid_copying_the_body_run() {
avoid_copying_the_body {|f|
- let builder = mk_task_builder();
+ let builder = task_builder();
run(builder) {||
f();
}
@@ -859,7 +860,7 @@ fn test_avoid_copying_the_body_run() {
#[test]
fn test_avoid_copying_the_body_run_listener() {
avoid_copying_the_body {|f|
- let builder = mk_task_builder();
+ let builder = task_builder();
run_listener(builder, fn~[move f](_po: comm::port<int>) {
f();
});
@@ -878,7 +879,7 @@ fn test_avoid_copying_the_body_try() {
#[test]
fn test_avoid_copying_the_body_future_task() {
avoid_copying_the_body {|f|
- let builder = mk_task_builder();
+ let builder = task_builder();
future_task(builder);
run(builder) {||
f();
@@ -889,7 +890,7 @@ fn test_avoid_copying_the_body_future_task() {
#[test]
fn test_avoid_copying_the_body_unsupervise() {
avoid_copying_the_body {|f|
- let builder = mk_task_builder();
+ let builder = task_builder();
unsupervise(builder);
run(builder) {||
f();
View
@@ -8,8 +8,8 @@ export is_not_empty;
export same_length;
export reserve;
export len;
-export init_fn;
-export init_elt;
+export from_fn;
+export from_elem;
export to_mut;
export from_mut;
export head;
@@ -129,7 +129,7 @@ Creates and initializes an immutable vector.
Creates an immutable vector of size `n_elts` and initializes the elements
to the value returned by the function `op`.
"]
-fn init_fn<T>(n_elts: uint, op: init_op<T>) -> [T] {
+fn from_fn<T>(n_elts: uint, op: init_op<T>) -> [T] {
let mut v = [];
reserve(v, n_elts);
let mut i: uint = 0u;
@@ -143,7 +143,7 @@ Creates and initializes an immutable vector.
Creates an immutable vector of size `n_elts` and initializes the elements
to the value `t`.
"]
-fn init_elt<T: copy>(n_elts: uint, t: T) -> [T] {
+fn from_elem<T: copy>(n_elts: uint, t: T) -> [T] {
let mut v = [];
reserve(v, n_elts);
let mut i: uint = 0u;
@@ -182,7 +182,7 @@ fn tailn<T: copy>(v: [const T], n: uint) -> [T] {
slice(v, n, len(v))
}
-// FIXME: This name is sort of confusing next to init_fn, etc
+// FIXME: This name is sort of confusing next to from_fn, etc
// but this is the name haskell uses for this function,
// along with head/tail/last.
#[doc = "Returns all but the last elemnt of a vector"]
@@ -999,16 +999,16 @@ mod tests {
}
#[test]
- fn test_init_fn() {
- // Test on-stack init_fn.
- let v = init_fn(3u, square);
+ fn test_from_fn() {
+ // Test on-stack from_fn.
+ let v = from_fn(3u, square);
assert (len(v) == 3u);
assert (v[0] == 0u);
assert (v[1] == 1u);
assert (v[2] == 4u);
- // Test on-heap init_fn.
- v = init_fn(5u, square);
+ // Test on-heap from_fn.
+ v = from_fn(5u, square);
assert (len(v) == 5u);
assert (v[0] == 0u);
assert (v[1] == 1u);
@@ -1018,15 +1018,15 @@ mod tests {
}
#[test]
- fn test_init_elt() {
- // Test on-stack init_elt.
- let v = init_elt(2u, 10u);
+ fn test_from_elem() {
+ // Test on-stack from_elem.
+ let v = from_elem(2u, 10u);
assert (len(v) == 2u);
assert (v[0] == 10u);
assert (v[1] == 10u);
- // Test on-heap init_elt.
- v = init_elt(6u, 20u);
+ // Test on-heap from_elem.
+ v = from_elem(6u, 20u);
assert (v[0] == 20u);
assert (v[1] == 20u);
assert (v[2] == 20u);
View
@@ -37,7 +37,7 @@ Constructs a bitvector
"]
fn create(nbits: uint, init: bool) -> t {
let elt = if init { !0u } else { 0u };
- let storage = vec::to_mut(vec::init_elt(nbits / uint_bits + 1u, elt));
+ let storage = vec::to_mut(vec::from_elem(nbits / uint_bits + 1u, elt));
ret @{storage: storage, nbits: nbits};
}
@@ -84,7 +84,7 @@ fn assign(v0: t, v1: t) -> bool { let sub = right; ret process(v0, v1, sub); }
#[doc = "Makes a copy of a bitvector"]
fn clone(v: t) -> t {
- let storage = vec::to_mut(vec::init_elt(v.nbits / uint_bits + 1u, 0u));
+ let storage = vec::to_mut(vec::from_elem(v.nbits / uint_bits + 1u, 0u));
let len = vec::len(v.storage);
uint::range(0u, len) {|i| storage[i] = v.storage[i]; };
ret @{storage: storage, nbits: v.nbits};
@@ -190,7 +190,7 @@ Each uint in the resulting vector has either value 0u or 1u.
"]
fn to_vec(v: t) -> [uint] {
let sub = bind init_to_vec(v, _);
- ret vec::init_fn::<uint>(v.nbits, sub);
+ ret vec::from_fn::<uint>(v.nbits, sub);
}
@@ -232,7 +232,7 @@ mod tests {
let act;
let exp;
act = create(0u, false);
- exp = vec::init_elt::<uint>(0u, 0u);
+ exp = vec::from_elem::<uint>(0u, 0u);
assert (eq_vec(act, exp));
}
View
@@ -26,7 +26,7 @@ taken to ensure that a reference to the c_vec::t is still held if needed.
"];
export t;
-export create, create_with_dtor;
+export c_vec, c_vec_with_dtor;
export get, set;
export len;
export ptr;
@@ -60,7 +60,7 @@ Create a c_vec::t from a native buffer with a given length.
* base - A native pointer to a buffer
* len - The number of elements in the buffer
"]
-unsafe fn create<T>(base: *mutable T, len: uint) -> t<T> {
+unsafe fn c_vec<T>(base: *mutable T, len: uint) -> t<T> {
ret t({base: base,
len: len,
rsrc: @dtor_res(option::none)
@@ -78,7 +78,7 @@ and a function to run upon destruction.
* dtor - A function to run when the value is destructed, useful
for freeing the buffer, etc.
"]
-unsafe fn create_with_dtor<T>(base: *mutable T, len: uint, dtor: fn@())
+unsafe fn c_vec_with_dtor<T>(base: *mutable T, len: uint, dtor: fn@())
-> t<T> {
ret t({base: base,
len: len,
@@ -133,8 +133,8 @@ mod tests {
assert mem as int != 0;
- ret unsafe { create_with_dtor(mem as *mutable u8, n,
- bind free(mem)) };
+ ret unsafe { c_vec_with_dtor(mem as *mutable u8, n,
+ bind free(mem)) };
}
#[test]
Oops, something went wrong.

0 comments on commit cd72b1f

Please sign in to comment.