Skip to content

Commit 7c7140d

Browse files
committed
---
yaml --- r: 30687 b: refs/heads/incoming c: 6267d8a h: refs/heads/master i: 30685: f5318f8 30683: 14dfa0f 30679: 4c32d7e 30671: f82919c 30655: 0169c36 v: v3
1 parent 6e49c2f commit 7c7140d

File tree

3 files changed

+74
-81
lines changed

3 files changed

+74
-81
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9-
refs/heads/incoming: f3d6c506a4c614dfd7ecf6c119f13107719cc6b1
9+
refs/heads/incoming: 6267d8a94a7a215be446f5a431a1aae029a4e357
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libcore/at_vec.rs

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,24 @@
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-
135
/// Code for dealing with @-vectors. This is pretty incomplete, and
146
/// contains a bunch of duplication from the code for ~-vectors.
157
168
#[abi = "cdecl"]
179
extern mod rustrt {
18-
#[legacy_exports];
19-
fn vec_reserve_shared_actual(++t: *sys::TypeDesc,
10+
pub fn vec_reserve_shared_actual(++t: *sys::TypeDesc,
2011
++v: **vec::raw::VecRepr,
2112
++n: libc::size_t);
2213
}
2314

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

3020
/// Returns the number of elements the vector can hold without reallocating
3121
#[inline(always)]
32-
pure fn capacity<T>(&&v: @[const T]) -> uint {
22+
pub pure fn capacity<T>(&&v: @[const T]) -> uint {
3323
unsafe {
3424
let repr: **raw::VecRepr =
3525
::cast::reinterpret_cast(&addr_of(v));
@@ -50,7 +40,8 @@ pure fn capacity<T>(&&v: @[const T]) -> uint {
5040
* onto the vector being constructed.
5141
*/
5242
#[inline(always)]
53-
pure fn build_sized<A>(size: uint, builder: fn(push: pure fn(+A))) -> @[A] {
43+
pub pure fn build_sized<A>(size: uint,
44+
builder: fn(push: pure fn(+A))) -> @[A] {
5445
let mut vec = @[];
5546
unsafe { raw::reserve(vec, size); }
5647
builder(|+x| unsafe { raw::push(vec, move x) });
@@ -68,7 +59,7 @@ pure fn build_sized<A>(size: uint, builder: fn(push: pure fn(+A))) -> @[A] {
6859
* onto the vector being constructed.
6960
*/
7061
#[inline(always)]
71-
pure fn build<A>(builder: fn(push: pure fn(+A))) -> @[A] {
62+
pub pure fn build<A>(builder: fn(push: pure fn(+A))) -> @[A] {
7263
build_sized(4, builder)
7364
}
7465

@@ -85,7 +76,7 @@ pure fn build<A>(builder: fn(push: pure fn(+A))) -> @[A] {
8576
* onto the vector being constructed.
8677
*/
8778
#[inline(always)]
88-
pure fn build_sized_opt<A>(size: Option<uint>,
79+
pub pure fn build_sized_opt<A>(size: Option<uint>,
8980
builder: fn(push: pure fn(+A))) -> @[A] {
9081
build_sized(size.get_default(4), builder)
9182
}
@@ -101,7 +92,7 @@ pure fn append<T: Copy>(lhs: @[T], rhs: &[const T]) -> @[T] {
10192

10293

10394
/// Apply a function to each element of a vector and return the results
104-
pure fn map<T, U>(v: &[T], f: fn(T) -> U) -> @[U] {
95+
pub pure fn map<T, U>(v: &[T], f: fn(T) -> U) -> @[U] {
10596
do build_sized(v.len()) |push| {
10697
for vec::each(v) |elem| {
10798
push(f(*elem));
@@ -115,7 +106,7 @@ pure fn map<T, U>(v: &[T], f: fn(T) -> U) -> @[U] {
115106
* Creates an immutable vector of size `n_elts` and initializes the elements
116107
* to the value returned by the function `op`.
117108
*/
118-
pure fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> @[T] {
109+
pub pure fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> @[T] {
119110
do build_sized(n_elts) |push| {
120111
let mut i: uint = 0u;
121112
while i < n_elts { push(op(i)); i += 1u; }
@@ -128,7 +119,7 @@ pure fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> @[T] {
128119
* Creates an immutable vector of size `n_elts` and initializes the elements
129120
* to the value `t`.
130121
*/
131-
pure fn from_elem<T: Copy>(n_elts: uint, t: T) -> @[T] {
122+
pub pure fn from_elem<T: Copy>(n_elts: uint, t: T) -> @[T] {
132123
do build_sized(n_elts) |push| {
133124
let mut i: uint = 0u;
134125
while i < n_elts { push(t); i += 1u; }
@@ -137,7 +128,6 @@ pure fn from_elem<T: Copy>(n_elts: uint, t: T) -> @[T] {
137128

138129
#[cfg(notest)]
139130
mod traits {
140-
#[legacy_exports];
141131
#[cfg(stage0)]
142132
impl<T: Copy> @[T]: Add<&[const T],@[T]> {
143133
#[inline(always)]
@@ -159,10 +149,9 @@ mod traits {
159149
mod traits {
160150
#[legacy_exports];}
161151

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

167156
/**
168157
* Sets the length of a vector
@@ -172,13 +161,13 @@ mod raw {
172161
* the vector is actually the specified size.
173162
*/
174163
#[inline(always)]
175-
unsafe fn set_len<T>(&&v: @[const T], new_len: uint) {
164+
pub unsafe fn set_len<T>(&&v: @[const T], new_len: uint) {
176165
let repr: **VecRepr = ::cast::reinterpret_cast(&addr_of(v));
177166
(**repr).unboxed.fill = new_len * sys::size_of::<T>();
178167
}
179168

180169
#[inline(always)]
181-
unsafe fn push<T>(&v: @[const T], +initval: T) {
170+
pub unsafe fn push<T>(&v: @[const T], +initval: T) {
182171
let repr: **VecRepr = ::cast::reinterpret_cast(&addr_of(v));
183172
let fill = (**repr).unboxed.fill;
184173
if (**repr).unboxed.alloc > fill {
@@ -215,7 +204,7 @@ mod raw {
215204
* * v - A vector
216205
* * n - The number of elements to reserve space for
217206
*/
218-
unsafe fn reserve<T>(&v: @[const T], n: uint) {
207+
pub unsafe fn reserve<T>(&v: @[const T], n: uint) {
219208
// Only make the (slow) call into the runtime if we have to
220209
if capacity(v) < n {
221210
let ptr = addr_of(v) as **VecRepr;
@@ -239,7 +228,7 @@ mod raw {
239228
* * v - A vector
240229
* * n - The number of elements to reserve space for
241230
*/
242-
unsafe fn reserve_at_least<T>(&v: @[const T], n: uint) {
231+
pub unsafe fn reserve_at_least<T>(&v: @[const T], n: uint) {
243232
reserve(v, uint::next_power_of_two(n));
244233
}
245234

branches/incoming/src/libcore/extfmt.rs

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

4343
// Functions used by the fmt extension at compile time
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,
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,
7170
}
7271

7372
// A formatted conversion from an expression to a string
74-
type Conv =
73+
pub type Conv =
7574
{param: Option<int>,
7675
flags: ~[Flag],
7776
width: Count,
@@ -80,10 +79,10 @@ mod ct {
8079

8180

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

86-
fn parse_fmt_string(s: ~str, error: ErrorFn) -> ~[Piece] {
85+
pub fn parse_fmt_string(s: ~str, error: ErrorFn) -> ~[Piece] {
8786
let mut pieces: ~[Piece] = ~[];
8887
let lim = str::len(s);
8988
let mut buf = ~"";
@@ -273,21 +272,26 @@ mod ct {
273272
// decisions made a runtime. If it proves worthwhile then some of these
274273
// conditions can be evaluated at compile-time. For now though it's cleaner to
275274
// implement it 0this way, I think.
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 {
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 {
291295
let radix = 10u;
292296
let prec = get_int_precision(cv);
293297
let mut s : ~str = int_to_str_prec(i, radix, prec);
@@ -300,7 +304,7 @@ mod rt {
300304
}
301305
return unsafe { pad(cv, s, PadSigned) };
302306
}
303-
pure fn conv_uint(cv: Conv, u: uint) -> ~str {
307+
pub pure fn conv_uint(cv: Conv, u: uint) -> ~str {
304308
let prec = get_int_precision(cv);
305309
let mut rs =
306310
match cv.ty {
@@ -312,17 +316,17 @@ mod rt {
312316
};
313317
return unsafe { pad(cv, rs, PadUnsigned) };
314318
}
315-
pure fn conv_bool(cv: Conv, b: bool) -> ~str {
319+
pub pure fn conv_bool(cv: Conv, b: bool) -> ~str {
316320
let s = if b { ~"true" } else { ~"false" };
317321
// run the boolean conversion through the string conversion logic,
318322
// giving it the same rules for precision, etc.
319323
return conv_str(cv, s);
320324
}
321-
pure fn conv_char(cv: Conv, c: char) -> ~str {
325+
pub pure fn conv_char(cv: Conv, c: char) -> ~str {
322326
let mut s = str::from_char(c);
323327
return unsafe { pad(cv, s, PadNozero) };
324328
}
325-
pure fn conv_str(cv: Conv, s: &str) -> ~str {
329+
pub pure fn conv_str(cv: Conv, s: &str) -> ~str {
326330
// For strings, precision is the maximum characters
327331
// displayed
328332
let mut unpadded = match cv.precision {
@@ -335,7 +339,7 @@ mod rt {
335339
};
336340
return unsafe { pad(cv, unpadded, PadNozero) };
337341
}
338-
pure fn conv_float(cv: Conv, f: float) -> ~str {
342+
pub pure fn conv_float(cv: Conv, f: float) -> ~str {
339343
let (to_str, digits) = match cv.precision {
340344
CountIs(c) => (float::to_str_exact, c as uint),
341345
CountImplied => (float::to_str, 6u)
@@ -350,7 +354,7 @@ mod rt {
350354
}
351355
return unsafe { pad(cv, s, PadFloat) };
352356
}
353-
pure fn conv_poly<T>(cv: Conv, v: T) -> ~str {
357+
pub pure fn conv_poly<T>(cv: Conv, v: T) -> ~str {
354358
let s = sys::log_str(&v);
355359
return conv_str(cv, s);
356360
}

0 commit comments

Comments
 (0)