Skip to content

Commit e1dcbef

Browse files
ericktalexcrichton
authored andcommitted
remove serialize::ebml, add librbml
Our implementation of ebml has diverged from the standard in order to better serve the needs of the compiler, so it doesn't make much sense to call what we have ebml anyore. Furthermore, our implementation is pretty crufty, and should eventually be rewritten into a format that better suits the needs of the compiler. This patch factors out serialize::ebml into librbml, otherwise known as the Really Bad Markup Language. This is a stopgap library that shouldn't be used by end users, and will eventually be replaced by something better. [breaking-change]
1 parent ea1b637 commit e1dcbef

File tree

12 files changed

+897
-879
lines changed

12 files changed

+897
-879
lines changed

mk/crates.mk

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
TARGET_CRATES := libc std green rustuv native flate arena glob term semver \
5353
uuid serialize sync getopts collections num test time rand \
54-
url log regex graphviz core rlibc alloc debug rustrt \
54+
url log regex graphviz core rbml rlibc alloc debug rustrt \
5555
unicode
5656
HOST_CRATES := syntax rustc rustdoc fourcc hexfloat regex_macros fmt_macros \
5757
rustc_llvm rustc_back
@@ -71,7 +71,7 @@ DEPS_green := std native:context_switch
7171
DEPS_rustuv := std native:uv native:uv_support
7272
DEPS_native := std
7373
DEPS_syntax := std term serialize log fmt_macros debug
74-
DEPS_rustc := syntax flate arena serialize getopts \
74+
DEPS_rustc := syntax flate arena serialize getopts rbml \
7575
time log graphviz debug rustc_llvm rustc_back
7676
DEPS_rustc_llvm := native:rustllvm libc std
7777
DEPS_rustc_back := std syntax rustc_llvm flate log libc
@@ -82,6 +82,7 @@ DEPS_arena := std
8282
DEPS_graphviz := std
8383
DEPS_glob := std
8484
DEPS_serialize := std log
85+
DEPS_rbml := std log serialize
8586
DEPS_term := std log
8687
DEPS_semver := std
8788
DEPS_uuid := std serialize
@@ -91,7 +92,7 @@ DEPS_collections := core alloc unicode
9192
DEPS_fourcc := rustc syntax std
9293
DEPS_hexfloat := rustc syntax std
9394
DEPS_num := std
94-
DEPS_test := std getopts serialize term time regex native:rust_test_helpers
95+
DEPS_test := std getopts serialize rbml term time regex native:rust_test_helpers
9596
DEPS_time := std serialize
9697
DEPS_rand := core
9798
DEPS_url := std

src/libserialize/ebml.rs renamed to src/librbml/lib.rs

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,35 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
//! Really Bad Markup Language (rbml) is a temporary measure until we migrate
12+
//! the rust object metadata to a better serialization format. It is not
13+
//! intended to be used by users.
14+
//!
15+
//! It is loosely based on the Extensible Binary Markup Language (ebml):
16+
//! http://www.matroska.org/technical/specs/rfc/index.html
17+
18+
#![crate_name = "rbml"]
19+
#![experimental]
20+
#![crate_type = "rlib"]
21+
#![crate_type = "dylib"]
22+
#![license = "MIT/ASL2"]
23+
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
24+
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
25+
html_root_url = "http://doc.rust-lang.org/master/",
26+
html_playground_url = "http://play.rust-lang.org/")]
27+
#![feature(macro_rules, phase)]
1128
#![allow(missing_doc)]
1229

30+
extern crate serialize;
31+
32+
#[phase(plugin, link)] extern crate log;
33+
#[cfg(test)] extern crate test;
34+
1335
use std::io;
1436
use std::str;
1537

16-
// Simple Extensible Binary Markup Language (ebml) reader and writer on a
17-
// cursor model. See the specification here:
18-
// http://www.matroska.org/technical/specs/rfc/index.html
1938

20-
// Common data structures
39+
/// Common data structures
2140
#[deriving(Clone)]
2241
pub struct Doc<'a> {
2342
pub data: &'a [u8],
@@ -107,7 +126,7 @@ pub mod reader {
107126
Expected };
108127

109128
pub type DecodeResult<T> = Result<T, Error>;
110-
// ebml reading
129+
// rbml reading
111130

112131
macro_rules! try_or(
113132
($e:expr, $r:expr) => (
@@ -637,7 +656,7 @@ pub mod writer {
637656

638657
pub type EncodeResult = io::IoResult<()>;
639658

640-
// ebml writing
659+
// rbml writing
641660
pub struct Encoder<'a, W> {
642661
pub writer: &'a mut W,
643662
size_positions: Vec<uint>,
@@ -671,7 +690,7 @@ pub mod writer {
671690
})
672691
}
673692

674-
// FIXME (#2741): Provide a function to write the standard ebml header.
693+
// FIXME (#2741): Provide a function to write the standard rbml header.
675694
impl<'a, W: Writer + Seek> Encoder<'a, W> {
676695
pub fn new(w: &'a mut W) -> Encoder<'a, W> {
677696
Encoder {
@@ -1018,10 +1037,8 @@ pub mod writer {
10181037

10191038
#[cfg(test)]
10201039
mod tests {
1021-
use super::Doc;
1022-
use ebml::reader;
1023-
use ebml::writer;
1024-
use {Encodable, Decodable};
1040+
use super::{Doc, reader, writer};
1041+
use serialize::{Encodable, Decodable};
10251042

10261043
use std::io::{IoError, IoResult, SeekStyle};
10271044
use std::io;
@@ -1196,11 +1213,11 @@ mod tests {
11961213
debug!("v == {}", v);
11971214
let mut wr = SeekableMemWriter::new();
11981215
{
1199-
let mut ebml_w = writer::Encoder::new(&mut wr);
1200-
let _ = v.encode(&mut ebml_w);
1216+
let mut rbml_w = writer::Encoder::new(&mut wr);
1217+
let _ = v.encode(&mut rbml_w);
12011218
}
1202-
let ebml_doc = Doc::new(wr.get_ref());
1203-
let mut deser = reader::Decoder::new(ebml_doc);
1219+
let rbml_doc = Doc::new(wr.get_ref());
1220+
let mut deser = reader::Decoder::new(rbml_doc);
12041221
let v1 = Decodable::decode(&mut deser).unwrap();
12051222
debug!("v1 == {}", v1);
12061223
assert_eq!(v, v1);
@@ -1215,9 +1232,8 @@ mod tests {
12151232
#[cfg(test)]
12161233
mod bench {
12171234
#![allow(non_snake_case_functions)]
1218-
extern crate test;
1219-
use self::test::Bencher;
1220-
use ebml::reader;
1235+
use test::Bencher;
1236+
use super::reader;
12211237

12221238
#[bench]
12231239
pub fn vuint_at_A_aligned(b: &mut Bencher) {

src/librustc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ extern crate libc;
4444
extern crate llvm = "rustc_llvm";
4545
extern crate rustc_back = "rustc_back";
4646
extern crate serialize;
47+
extern crate rbml;
4748
extern crate time;
4849
#[phase(plugin, link)] extern crate log;
4950
#[phase(plugin, link)] extern crate syntax;

src/librustc/metadata/csearch.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ use middle::ty;
2020
use middle::typeck;
2121
use middle::subst::VecPerParamSpace;
2222

23-
use serialize::ebml;
24-
use serialize::ebml::reader;
23+
use rbml;
24+
use rbml::reader;
2525
use std::rc::Rc;
2626
use syntax::ast;
2727
use syntax::ast_map;
@@ -218,7 +218,7 @@ pub fn get_field_type(tcx: &ty::ctxt, class_id: ast::DefId,
218218
def: ast::DefId) -> ty::Polytype {
219219
let cstore = &tcx.sess.cstore;
220220
let cdata = cstore.get_crate_data(class_id.krate);
221-
let all_items = reader::get_doc(ebml::Doc::new(cdata.data()), tag_items);
221+
let all_items = reader::get_doc(rbml::Doc::new(cdata.data()), tag_items);
222222
let class_doc = expect(tcx.sess.diagnostic(),
223223
decoder::maybe_find_item(class_id.node, all_items),
224224
|| {

0 commit comments

Comments
 (0)