Skip to content

Commit fb83b40

Browse files
committed
De-export std::{ebml, ebml2}. Part of #3583.
1 parent 009a380 commit fb83b40

File tree

3 files changed

+41
-89
lines changed

3 files changed

+41
-89
lines changed

src/libstd/ebml.rs

+22-47
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,6 @@
44
use core::Option;
55
use option::{Some, None};
66

7-
export Doc;
8-
export doc_at;
9-
export maybe_get_doc;
10-
export get_doc;
11-
export docs;
12-
export tagged_docs;
13-
export doc_data;
14-
export doc_as_str;
15-
export doc_as_u8;
16-
export doc_as_u16;
17-
export doc_as_u32;
18-
export doc_as_u64;
19-
export doc_as_i8;
20-
export doc_as_i16;
21-
export doc_as_i32;
22-
export doc_as_i64;
23-
export Writer;
24-
export serializer;
25-
export ebml_deserializer;
26-
export EbmlDeserializer;
27-
export deserializer;
28-
export with_doc_data;
29-
export get_doc;
30-
export extensions;
31-
327
type EbmlTag = {id: uint, size: uint};
338

349
type EbmlState = {ebml_tag: EbmlTag, tag_pos: uint, data_pos: uint};
@@ -37,7 +12,7 @@ type EbmlState = {ebml_tag: EbmlTag, tag_pos: uint, data_pos: uint};
3712
// separate modules within this file.
3813

3914
// ebml reading
40-
type Doc = {data: @~[u8], start: uint, end: uint};
15+
pub type Doc = {data: @~[u8], start: uint, end: uint};
4116

4217
type TaggedDoc = {tag: uint, doc: Doc};
4318

@@ -72,19 +47,19 @@ fn vuint_at(data: &[u8], start: uint) -> {val: uint, next: uint} {
7247
} else { error!("vint too big"); fail; }
7348
}
7449

75-
fn Doc(data: @~[u8]) -> Doc {
50+
pub fn Doc(data: @~[u8]) -> Doc {
7651
return {data: data, start: 0u, end: vec::len::<u8>(*data)};
7752
}
7853

79-
fn doc_at(data: @~[u8], start: uint) -> TaggedDoc {
54+
pub fn doc_at(data: @~[u8], start: uint) -> TaggedDoc {
8055
let elt_tag = vuint_at(*data, start);
8156
let elt_size = vuint_at(*data, elt_tag.next);
8257
let end = elt_size.next + elt_size.val;
8358
return {tag: elt_tag.val,
8459
doc: {data: data, start: elt_size.next, end: end}};
8560
}
8661

87-
fn maybe_get_doc(d: Doc, tg: uint) -> Option<Doc> {
62+
pub fn maybe_get_doc(d: Doc, tg: uint) -> Option<Doc> {
8863
let mut pos = d.start;
8964
while pos < d.end {
9065
let elt_tag = vuint_at(*d.data, pos);
@@ -101,7 +76,7 @@ fn maybe_get_doc(d: Doc, tg: uint) -> Option<Doc> {
10176
return None::<Doc>;
10277
}
10378

104-
fn get_doc(d: Doc, tg: uint) -> Doc {
79+
pub fn get_doc(d: Doc, tg: uint) -> Doc {
10580
match maybe_get_doc(d, tg) {
10681
Some(d) => return d,
10782
None => {
@@ -111,7 +86,7 @@ fn get_doc(d: Doc, tg: uint) -> Doc {
11186
}
11287
}
11388

114-
fn docs(d: Doc, it: fn(uint, Doc) -> bool) {
89+
pub fn docs(d: Doc, it: fn(uint, Doc) -> bool) {
11590
let mut pos = d.start;
11691
while pos < d.end {
11792
let elt_tag = vuint_at(*d.data, pos);
@@ -123,7 +98,7 @@ fn docs(d: Doc, it: fn(uint, Doc) -> bool) {
12398
}
12499
}
125100

126-
fn tagged_docs(d: Doc, tg: uint, it: fn(Doc) -> bool) {
101+
pub fn tagged_docs(d: Doc, tg: uint, it: fn(Doc) -> bool) {
127102
let mut pos = d.start;
128103
while pos < d.end {
129104
let elt_tag = vuint_at(*d.data, pos);
@@ -137,43 +112,43 @@ fn tagged_docs(d: Doc, tg: uint, it: fn(Doc) -> bool) {
137112
}
138113
}
139114

140-
fn doc_data(d: Doc) -> ~[u8] { vec::slice::<u8>(*d.data, d.start, d.end) }
115+
pub fn doc_data(d: Doc) -> ~[u8] { vec::slice::<u8>(*d.data, d.start, d.end) }
141116

142-
fn with_doc_data<T>(d: Doc, f: fn(x: &[u8]) -> T) -> T {
117+
pub fn with_doc_data<T>(d: Doc, f: fn(x: &[u8]) -> T) -> T {
143118
return f(vec::view(*d.data, d.start, d.end));
144119
}
145120

146-
fn doc_as_str(d: Doc) -> ~str { return str::from_bytes(doc_data(d)); }
121+
pub fn doc_as_str(d: Doc) -> ~str { return str::from_bytes(doc_data(d)); }
147122

148-
fn doc_as_u8(d: Doc) -> u8 {
123+
pub fn doc_as_u8(d: Doc) -> u8 {
149124
assert d.end == d.start + 1u;
150125
return (*d.data)[d.start];
151126
}
152127

153-
fn doc_as_u16(d: Doc) -> u16 {
128+
pub fn doc_as_u16(d: Doc) -> u16 {
154129
assert d.end == d.start + 2u;
155130
return io::u64_from_be_bytes(*d.data, d.start, 2u) as u16;
156131
}
157132

158-
fn doc_as_u32(d: Doc) -> u32 {
133+
pub fn doc_as_u32(d: Doc) -> u32 {
159134
assert d.end == d.start + 4u;
160135
return io::u64_from_be_bytes(*d.data, d.start, 4u) as u32;
161136
}
162137

163-
fn doc_as_u64(d: Doc) -> u64 {
138+
pub fn doc_as_u64(d: Doc) -> u64 {
164139
assert d.end == d.start + 8u;
165140
return io::u64_from_be_bytes(*d.data, d.start, 8u);
166141
}
167142

168-
fn doc_as_i8(d: Doc) -> i8 { doc_as_u8(d) as i8 }
169-
fn doc_as_i16(d: Doc) -> i16 { doc_as_u16(d) as i16 }
170-
fn doc_as_i32(d: Doc) -> i32 { doc_as_u32(d) as i32 }
171-
fn doc_as_i64(d: Doc) -> i64 { doc_as_u64(d) as i64 }
143+
pub fn doc_as_i8(d: Doc) -> i8 { doc_as_u8(d) as i8 }
144+
pub fn doc_as_i16(d: Doc) -> i16 { doc_as_u16(d) as i16 }
145+
pub fn doc_as_i32(d: Doc) -> i32 { doc_as_u32(d) as i32 }
146+
pub fn doc_as_i64(d: Doc) -> i64 { doc_as_u64(d) as i64 }
172147

173148
// ebml writing
174149
type Writer_ = {writer: io::Writer, mut size_positions: ~[uint]};
175150

176-
enum Writer {
151+
pub enum Writer {
177152
Writer_(Writer_)
178153
}
179154

@@ -197,7 +172,7 @@ fn write_vuint(w: io::Writer, n: uint) {
197172
fail fmt!("vint to write too big: %?", n);
198173
}
199174

200-
fn Writer(w: io::Writer) -> Writer {
175+
pub fn Writer(w: io::Writer) -> Writer {
201176
let size_positions: ~[uint] = ~[];
202177
return Writer_({writer: w, mut size_positions: size_positions});
203178
}
@@ -409,11 +384,11 @@ impl ebml::Writer: serialization::Serializer {
409384
type EbmlDeserializer_ = {mut parent: ebml::Doc,
410385
mut pos: uint};
411386

412-
enum EbmlDeserializer {
387+
pub enum EbmlDeserializer {
413388
EbmlDeserializer_(EbmlDeserializer_)
414389
}
415390

416-
fn ebml_deserializer(d: ebml::Doc) -> EbmlDeserializer {
391+
pub fn ebml_deserializer(d: ebml::Doc) -> EbmlDeserializer {
417392
EbmlDeserializer_({mut parent: d, mut pos: d.start})
418393
}
419394

src/libstd/ebml2.rs

+19-40
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,6 @@ use serialization2;
33
// Simple Extensible Binary Markup Language (ebml) reader and writer on a
44
// cursor model. See the specification here:
55
// http://www.matroska.org/technical/specs/rfc/index.html
6-
export Doc;
7-
export doc_at;
8-
export maybe_get_doc;
9-
export get_doc;
10-
export docs;
11-
export tagged_docs;
12-
export doc_data;
13-
export doc_as_str;
14-
export doc_as_u8;
15-
export doc_as_u16;
16-
export doc_as_u32;
17-
export doc_as_u64;
18-
export doc_as_i8;
19-
export doc_as_i16;
20-
export doc_as_i32;
21-
export doc_as_i64;
22-
export Serializer;
23-
export Deserializer;
24-
export with_doc_data;
25-
export get_doc;
26-
export extensions;
276

287
struct EbmlTag {
298
id: uint,
@@ -82,11 +61,11 @@ fn vuint_at(data: &[u8], start: uint) -> {val: uint, next: uint} {
8261
} else { error!("vint too big"); fail; }
8362
}
8463

85-
fn Doc(data: @~[u8]) -> Doc {
64+
pub fn Doc(data: @~[u8]) -> Doc {
8665
Doc { data: data, start: 0u, end: vec::len::<u8>(*data) }
8766
}
8867

89-
fn doc_at(data: @~[u8], start: uint) -> TaggedDoc {
68+
pub fn doc_at(data: @~[u8], start: uint) -> TaggedDoc {
9069
let elt_tag = vuint_at(*data, start);
9170
let elt_size = vuint_at(*data, elt_tag.next);
9271
let end = elt_size.next + elt_size.val;
@@ -96,7 +75,7 @@ fn doc_at(data: @~[u8], start: uint) -> TaggedDoc {
9675
}
9776
}
9877

99-
fn maybe_get_doc(d: Doc, tg: uint) -> Option<Doc> {
78+
pub fn maybe_get_doc(d: Doc, tg: uint) -> Option<Doc> {
10079
let mut pos = d.start;
10180
while pos < d.end {
10281
let elt_tag = vuint_at(*d.data, pos);
@@ -109,7 +88,7 @@ fn maybe_get_doc(d: Doc, tg: uint) -> Option<Doc> {
10988
None
11089
}
11190

112-
fn get_doc(d: Doc, tg: uint) -> Doc {
91+
pub fn get_doc(d: Doc, tg: uint) -> Doc {
11392
match maybe_get_doc(d, tg) {
11493
Some(d) => d,
11594
None => {
@@ -119,7 +98,7 @@ fn get_doc(d: Doc, tg: uint) -> Doc {
11998
}
12099
}
121100

122-
fn docs(d: Doc, it: fn(uint, Doc) -> bool) {
101+
pub fn docs(d: Doc, it: fn(uint, Doc) -> bool) {
123102
let mut pos = d.start;
124103
while pos < d.end {
125104
let elt_tag = vuint_at(*d.data, pos);
@@ -132,7 +111,7 @@ fn docs(d: Doc, it: fn(uint, Doc) -> bool) {
132111
}
133112
}
134113

135-
fn tagged_docs(d: Doc, tg: uint, it: fn(Doc) -> bool) {
114+
pub fn tagged_docs(d: Doc, tg: uint, it: fn(Doc) -> bool) {
136115
let mut pos = d.start;
137116
while pos < d.end {
138117
let elt_tag = vuint_at(*d.data, pos);
@@ -147,38 +126,38 @@ fn tagged_docs(d: Doc, tg: uint, it: fn(Doc) -> bool) {
147126
}
148127
}
149128

150-
fn doc_data(d: Doc) -> ~[u8] { vec::slice::<u8>(*d.data, d.start, d.end) }
129+
pub fn doc_data(d: Doc) -> ~[u8] { vec::slice::<u8>(*d.data, d.start, d.end) }
151130

152-
fn with_doc_data<T>(d: Doc, f: fn(x: &[u8]) -> T) -> T {
131+
pub fn with_doc_data<T>(d: Doc, f: fn(x: &[u8]) -> T) -> T {
153132
f(vec::view(*d.data, d.start, d.end))
154133
}
155134

156-
fn doc_as_str(d: Doc) -> ~str { str::from_bytes(doc_data(d)) }
135+
pub fn doc_as_str(d: Doc) -> ~str { str::from_bytes(doc_data(d)) }
157136

158-
fn doc_as_u8(d: Doc) -> u8 {
137+
pub fn doc_as_u8(d: Doc) -> u8 {
159138
assert d.end == d.start + 1u;
160139
(*d.data)[d.start]
161140
}
162141

163-
fn doc_as_u16(d: Doc) -> u16 {
142+
pub fn doc_as_u16(d: Doc) -> u16 {
164143
assert d.end == d.start + 2u;
165144
io::u64_from_be_bytes(*d.data, d.start, 2u) as u16
166145
}
167146

168-
fn doc_as_u32(d: Doc) -> u32 {
147+
pub fn doc_as_u32(d: Doc) -> u32 {
169148
assert d.end == d.start + 4u;
170149
io::u64_from_be_bytes(*d.data, d.start, 4u) as u32
171150
}
172151

173-
fn doc_as_u64(d: Doc) -> u64 {
152+
pub fn doc_as_u64(d: Doc) -> u64 {
174153
assert d.end == d.start + 8u;
175154
io::u64_from_be_bytes(*d.data, d.start, 8u)
176155
}
177156

178-
fn doc_as_i8(d: Doc) -> i8 { doc_as_u8(d) as i8 }
179-
fn doc_as_i16(d: Doc) -> i16 { doc_as_u16(d) as i16 }
180-
fn doc_as_i32(d: Doc) -> i32 { doc_as_u32(d) as i32 }
181-
fn doc_as_i64(d: Doc) -> i64 { doc_as_u64(d) as i64 }
157+
pub fn doc_as_i8(d: Doc) -> i8 { doc_as_u8(d) as i8 }
158+
pub fn doc_as_i16(d: Doc) -> i16 { doc_as_u16(d) as i16 }
159+
pub fn doc_as_i32(d: Doc) -> i32 { doc_as_u32(d) as i32 }
160+
pub fn doc_as_i64(d: Doc) -> i64 { doc_as_u64(d) as i64 }
182161

183162
// ebml writing
184163
struct Serializer {
@@ -206,7 +185,7 @@ fn write_vuint(w: io::Writer, n: uint) {
206185
fail fmt!("vint to write too big: %?", n);
207186
}
208187

209-
fn Serializer(w: io::Writer) -> Serializer {
188+
pub fn Serializer(w: io::Writer) -> Serializer {
210189
let size_positions: ~[uint] = ~[];
211190
Serializer { writer: w, mut size_positions: size_positions }
212191
}
@@ -450,7 +429,7 @@ struct Deserializer {
450429
priv mut pos: uint,
451430
}
452431

453-
fn Deserializer(d: Doc) -> Deserializer {
432+
pub fn Deserializer(d: Doc) -> Deserializer {
454433
Deserializer { mut parent: d, mut pos: d.start }
455434
}
456435

src/libstd/std.rc

-2
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ mod treemap;
8989

9090
// And ... other stuff
9191

92-
#[legacy_exports]
9392
mod ebml;
94-
#[legacy_exports]
9593
mod ebml2;
9694
mod dbg;
9795
#[legacy_exports]

0 commit comments

Comments
 (0)