Skip to content

Commit ab7929b

Browse files
committed
---
yaml --- r: 32750 b: refs/heads/dist-snap c: 298ab6f h: refs/heads/master v: v3
1 parent 2a4e020 commit ab7929b

File tree

3 files changed

+81
-74
lines changed

3 files changed

+81
-74
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
10-
refs/heads/dist-snap: 6267d8a94a7a215be446f5a431a1aae029a4e357
10+
refs/heads/dist-snap: 298ab6f45957591d13104e8c667e83928d2276a4
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/dist-snap/src/libcore/at_vec.rs

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,34 @@
22
33
use ptr::addr_of;
44

5+
export init_op;
6+
export capacity;
7+
export build_sized, build, build_sized_opt;
8+
export map;
9+
export from_fn, from_elem;
10+
export raw;
11+
export traits;
12+
513
/// Code for dealing with @-vectors. This is pretty incomplete, and
614
/// contains a bunch of duplication from the code for ~-vectors.
715
816
#[abi = "cdecl"]
917
extern mod rustrt {
10-
pub fn vec_reserve_shared_actual(++t: *sys::TypeDesc,
18+
#[legacy_exports];
19+
fn vec_reserve_shared_actual(++t: *sys::TypeDesc,
1120
++v: **vec::raw::VecRepr,
1221
++n: libc::size_t);
1322
}
1423

1524
#[abi = "rust-intrinsic"]
1625
extern mod rusti {
17-
pub fn move_val_init<T>(&dst: T, -src: T);
26+
#[legacy_exports];
27+
fn move_val_init<T>(&dst: T, -src: T);
1828
}
1929

2030
/// Returns the number of elements the vector can hold without reallocating
2131
#[inline(always)]
22-
pub pure fn capacity<T>(&&v: @[const T]) -> uint {
32+
pure fn capacity<T>(&&v: @[const T]) -> uint {
2333
unsafe {
2434
let repr: **raw::VecRepr =
2535
::cast::reinterpret_cast(&addr_of(v));
@@ -40,8 +50,7 @@ pub pure fn capacity<T>(&&v: @[const T]) -> uint {
4050
* onto the vector being constructed.
4151
*/
4252
#[inline(always)]
43-
pub pure fn build_sized<A>(size: uint,
44-
builder: fn(push: pure fn(+A))) -> @[A] {
53+
pure fn build_sized<A>(size: uint, builder: fn(push: pure fn(+A))) -> @[A] {
4554
let mut vec = @[];
4655
unsafe { raw::reserve(vec, size); }
4756
builder(|+x| unsafe { raw::push(vec, move x) });
@@ -59,7 +68,7 @@ pub pure fn build_sized<A>(size: uint,
5968
* onto the vector being constructed.
6069
*/
6170
#[inline(always)]
62-
pub pure fn build<A>(builder: fn(push: pure fn(+A))) -> @[A] {
71+
pure fn build<A>(builder: fn(push: pure fn(+A))) -> @[A] {
6372
build_sized(4, builder)
6473
}
6574

@@ -76,7 +85,7 @@ pub pure fn build<A>(builder: fn(push: pure fn(+A))) -> @[A] {
7685
* onto the vector being constructed.
7786
*/
7887
#[inline(always)]
79-
pub pure fn build_sized_opt<A>(size: Option<uint>,
88+
pure fn build_sized_opt<A>(size: Option<uint>,
8089
builder: fn(push: pure fn(+A))) -> @[A] {
8190
build_sized(size.get_default(4), builder)
8291
}
@@ -92,7 +101,7 @@ pure fn append<T: Copy>(lhs: @[T], rhs: &[const T]) -> @[T] {
92101

93102

94103
/// Apply a function to each element of a vector and return the results
95-
pub pure fn map<T, U>(v: &[T], f: fn(T) -> U) -> @[U] {
104+
pure fn map<T, U>(v: &[T], f: fn(T) -> U) -> @[U] {
96105
do build_sized(v.len()) |push| {
97106
for vec::each(v) |elem| {
98107
push(f(*elem));
@@ -106,7 +115,7 @@ pub pure fn map<T, U>(v: &[T], f: fn(T) -> U) -> @[U] {
106115
* Creates an immutable vector of size `n_elts` and initializes the elements
107116
* to the value returned by the function `op`.
108117
*/
109-
pub pure fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> @[T] {
118+
pure fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> @[T] {
110119
do build_sized(n_elts) |push| {
111120
let mut i: uint = 0u;
112121
while i < n_elts { push(op(i)); i += 1u; }
@@ -119,7 +128,7 @@ pub pure fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> @[T] {
119128
* Creates an immutable vector of size `n_elts` and initializes the elements
120129
* to the value `t`.
121130
*/
122-
pub pure fn from_elem<T: Copy>(n_elts: uint, t: T) -> @[T] {
131+
pure fn from_elem<T: Copy>(n_elts: uint, t: T) -> @[T] {
123132
do build_sized(n_elts) |push| {
124133
let mut i: uint = 0u;
125134
while i < n_elts { push(t); i += 1u; }
@@ -128,6 +137,7 @@ pub pure fn from_elem<T: Copy>(n_elts: uint, t: T) -> @[T] {
128137

129138
#[cfg(notest)]
130139
mod traits {
140+
#[legacy_exports];
131141
#[cfg(stage0)]
132142
impl<T: Copy> @[T]: Add<&[const T],@[T]> {
133143
#[inline(always)]
@@ -149,9 +159,10 @@ mod traits {
149159
mod traits {
150160
#[legacy_exports];}
151161

152-
pub mod raw {
153-
pub type VecRepr = vec::raw::VecRepr;
154-
pub type SliceRepr = vec::raw::SliceRepr;
162+
mod raw {
163+
#[legacy_exports];
164+
type VecRepr = vec::raw::VecRepr;
165+
type SliceRepr = vec::raw::SliceRepr;
155166

156167
/**
157168
* Sets the length of a vector
@@ -161,13 +172,13 @@ pub mod raw {
161172
* the vector is actually the specified size.
162173
*/
163174
#[inline(always)]
164-
pub unsafe fn set_len<T>(&&v: @[const T], new_len: uint) {
175+
unsafe fn set_len<T>(&&v: @[const T], new_len: uint) {
165176
let repr: **VecRepr = ::cast::reinterpret_cast(&addr_of(v));
166177
(**repr).unboxed.fill = new_len * sys::size_of::<T>();
167178
}
168179

169180
#[inline(always)]
170-
pub unsafe fn push<T>(&v: @[const T], +initval: T) {
181+
unsafe fn push<T>(&v: @[const T], +initval: T) {
171182
let repr: **VecRepr = ::cast::reinterpret_cast(&addr_of(v));
172183
let fill = (**repr).unboxed.fill;
173184
if (**repr).unboxed.alloc > fill {
@@ -204,7 +215,7 @@ pub mod raw {
204215
* * v - A vector
205216
* * n - The number of elements to reserve space for
206217
*/
207-
pub unsafe fn reserve<T>(&v: @[const T], n: uint) {
218+
unsafe fn reserve<T>(&v: @[const T], n: uint) {
208219
// Only make the (slow) call into the runtime if we have to
209220
if capacity(v) < n {
210221
let ptr = addr_of(v) as **VecRepr;
@@ -228,7 +239,7 @@ pub mod raw {
228239
* * v - A vector
229240
* * n - The number of elements to reserve space for
230241
*/
231-
pub unsafe fn reserve_at_least<T>(&v: @[const T], n: uint) {
242+
unsafe fn reserve_at_least<T>(&v: @[const T], n: uint) {
232243
reserve(v, uint::next_power_of_two(n));
233244
}
234245

branches/dist-snap/src/libcore/extfmt.rs

Lines changed: 52 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -41,36 +41,37 @@ use option::{Some, None};
4141
*/
4242

4343
// Functions used by the fmt extension at compile time
44-
pub mod ct {
45-
pub enum Signedness { pub Signed, pub Unsigned, }
46-
pub enum Caseness { pub CaseUpper, pub CaseLower, }
47-
pub enum Ty {
48-
pub TyBool,
49-
pub TyStr,
50-
pub TyChar,
51-
pub TyInt(Signedness),
52-
pub TyBits,
53-
pub TyHex(Caseness),
54-
pub TyOctal,
55-
pub TyFloat,
56-
pub TyPoly,
57-
}
58-
pub enum Flag {
59-
pub FlagLeftJustify,
60-
pub FlagLeftZeroPad,
61-
pub FlagSpaceForSign,
62-
pub FlagSignAlways,
63-
pub FlagAlternate,
64-
}
65-
pub enum Count {
66-
pub CountIs(int),
67-
pub CountIsParam(int),
68-
pub CountIsNextParam,
69-
pub CountImplied,
44+
mod ct {
45+
#[legacy_exports];
46+
enum Signedness { Signed, Unsigned, }
47+
enum Caseness { CaseUpper, CaseLower, }
48+
enum Ty {
49+
TyBool,
50+
TyStr,
51+
TyChar,
52+
TyInt(Signedness),
53+
TyBits,
54+
TyHex(Caseness),
55+
TyOctal,
56+
TyFloat,
57+
TyPoly,
58+
}
59+
enum Flag {
60+
FlagLeftJustify,
61+
FlagLeftZeroPad,
62+
FlagSpaceForSign,
63+
FlagSignAlways,
64+
FlagAlternate,
65+
}
66+
enum Count {
67+
CountIs(int),
68+
CountIsParam(int),
69+
CountIsNextParam,
70+
CountImplied,
7071
}
7172

7273
// A formatted conversion from an expression to a string
73-
pub type Conv =
74+
type Conv =
7475
{param: Option<int>,
7576
flags: ~[Flag],
7677
width: Count,
@@ -79,10 +80,10 @@ pub mod ct {
7980

8081

8182
// A fragment of the output sequence
82-
pub enum Piece { PieceString(~str), PieceConv(Conv), }
83-
pub type ErrorFn = fn@(~str) -> ! ;
83+
enum Piece { PieceString(~str), PieceConv(Conv), }
84+
type ErrorFn = fn@(~str) -> ! ;
8485

85-
pub fn parse_fmt_string(s: ~str, error: ErrorFn) -> ~[Piece] {
86+
fn parse_fmt_string(s: ~str, error: ErrorFn) -> ~[Piece] {
8687
let mut pieces: ~[Piece] = ~[];
8788
let lim = str::len(s);
8889
let mut buf = ~"";
@@ -272,26 +273,21 @@ pub mod ct {
272273
// decisions made a runtime. If it proves worthwhile then some of these
273274
// conditions can be evaluated at compile-time. For now though it's cleaner to
274275
// implement it 0this way, I think.
275-
pub mod rt {
276-
pub const flag_none: u32 = 0u32;
277-
pub const flag_left_justify : u32 = 0b00000000000000000000000000000001u32;
278-
pub const flag_left_zero_pad: u32 = 0b00000000000000000000000000000010u32;
279-
pub const flag_space_for_sign:u32 = 0b00000000000000000000000000000100u32;
280-
pub const flag_sign_always : u32 = 0b00000000000000000000000000001000u32;
281-
pub const flag_alternate : u32 = 0b00000000000000000000000000010000u32;
282-
283-
pub enum Count { pub CountIs(int), pub CountImplied, }
284-
pub enum Ty {
285-
pub TyDefault,
286-
pub TyBits,
287-
pub TyHexUpper,
288-
pub TyHexLower,
289-
pub TyOctal
290-
}
291-
292-
pub type Conv = {flags: u32, width: Count, precision: Count, ty: Ty};
293-
294-
pub pure fn conv_int(cv: Conv, i: int) -> ~str {
276+
mod rt {
277+
#[legacy_exports];
278+
const flag_none : u32 = 0u32;
279+
const flag_left_justify : u32 = 0b00000000000000000000000000000001u32;
280+
const flag_left_zero_pad : u32 = 0b00000000000000000000000000000010u32;
281+
const flag_space_for_sign : u32 = 0b00000000000000000000000000000100u32;
282+
const flag_sign_always : u32 = 0b00000000000000000000000000001000u32;
283+
const flag_alternate : u32 = 0b00000000000000000000000000010000u32;
284+
285+
enum Count { CountIs(int), CountImplied, }
286+
enum Ty { TyDefault, TyBits, TyHexUpper, TyHexLower, TyOctal, }
287+
288+
type Conv = {flags: u32, width: Count, precision: Count, ty: Ty};
289+
290+
pure fn conv_int(cv: Conv, i: int) -> ~str {
295291
let radix = 10u;
296292
let prec = get_int_precision(cv);
297293
let mut s : ~str = int_to_str_prec(i, radix, prec);
@@ -304,7 +300,7 @@ pub mod rt {
304300
}
305301
return unsafe { pad(cv, s, PadSigned) };
306302
}
307-
pub pure fn conv_uint(cv: Conv, u: uint) -> ~str {
303+
pure fn conv_uint(cv: Conv, u: uint) -> ~str {
308304
let prec = get_int_precision(cv);
309305
let mut rs =
310306
match cv.ty {
@@ -316,17 +312,17 @@ pub mod rt {
316312
};
317313
return unsafe { pad(cv, rs, PadUnsigned) };
318314
}
319-
pub pure fn conv_bool(cv: Conv, b: bool) -> ~str {
315+
pure fn conv_bool(cv: Conv, b: bool) -> ~str {
320316
let s = if b { ~"true" } else { ~"false" };
321317
// run the boolean conversion through the string conversion logic,
322318
// giving it the same rules for precision, etc.
323319
return conv_str(cv, s);
324320
}
325-
pub pure fn conv_char(cv: Conv, c: char) -> ~str {
321+
pure fn conv_char(cv: Conv, c: char) -> ~str {
326322
let mut s = str::from_char(c);
327323
return unsafe { pad(cv, s, PadNozero) };
328324
}
329-
pub pure fn conv_str(cv: Conv, s: &str) -> ~str {
325+
pure fn conv_str(cv: Conv, s: &str) -> ~str {
330326
// For strings, precision is the maximum characters
331327
// displayed
332328
let mut unpadded = match cv.precision {
@@ -339,7 +335,7 @@ pub mod rt {
339335
};
340336
return unsafe { pad(cv, unpadded, PadNozero) };
341337
}
342-
pub pure fn conv_float(cv: Conv, f: float) -> ~str {
338+
pure fn conv_float(cv: Conv, f: float) -> ~str {
343339
let (to_str, digits) = match cv.precision {
344340
CountIs(c) => (float::to_str_exact, c as uint),
345341
CountImplied => (float::to_str, 6u)
@@ -354,7 +350,7 @@ pub mod rt {
354350
}
355351
return unsafe { pad(cv, s, PadFloat) };
356352
}
357-
pub pure fn conv_poly<T>(cv: Conv, v: T) -> ~str {
353+
pure fn conv_poly<T>(cv: Conv, v: T) -> ~str {
358354
let s = sys::log_str(&v);
359355
return conv_str(cv, s);
360356
}

0 commit comments

Comments
 (0)